get_image_tag_class

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

Description

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

Parameters (4)

0. $class (string)
CSS class name or space-separated list of classes.
1. $id (int)
Attachment ID.
2. $align (string)
Part of the class name for aligning the image.
3. $size (string|array)
Size of image. Image size or array of width and height values (in that order). Default medium..

Usage

To run the hook, copy the example below.
  1. $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size ); 
  2.  
  3. if ( !empty( $class ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the get_image_tag_class callback 
  2. function filter_get_image_tag_class( $class, $id, $align, $size ) { 
  3. // make filter magic happen here... 
  4. return $class
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'get_image_tag_class', 'filter_get_image_tag_class', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'get_image_tag_class', 'filter_get_image_tag_class', 10, 4 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/media.php  
  1. $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );