apply_filters( ‘get_image_tag_class’, string $class, int $id, string $align, string|int[] $size )

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

Parameters

$classstring
CSS class name or space-separated list of classes.
$idint
Attachment ID.
$alignstring
Part of the class name for aligning the image.
$sizestring|int[]
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).

Source

$class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );

Changelog

VersionDescription
2.6.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    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.