apply_filters( 'get_image_tag_class', string $class, int $id, string $align, string|array $size )

Filters the value of the attachment’s image tag class attribute.

Parameters Parameters


(string) CSS class name or space-separated list of classes.


(int) Attachment ID.


(string) Part of the class name for aligning the image.


(string|array) Size of image. Image size or array of width and height values (in that order). Default 'medium'.

Top ↑

Source Source

File: wp-includes/media.php

View on Trac

Top ↑

Changelog Changelog

Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Emil Frisk

    To add the .img-fluid class, for responsive images in Bootstrap 4:

    function example_add_img_class( $class ) {
    	return $class . ' img-fluid';
    add_filter( 'get_image_tag_class', 'example_add_img_class' );

You must log in before being able to contribute a note or feedback.