get_image_tag_class
Filter HookDescription
Filters the value of the attachment's image tag class attribute.Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 409 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$class
|
CSS class name or space-separated list of classes. |
int
|
$id
|
Attachment ID. |
string
|
$align
|
Part of the class name for aligning the image. |
string|int[]
|
$size
|
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order). |
Usage Examples
Basic Usage
<?php
// Hook into get_image_tag_class
add_filter('get_image_tag_class', 'my_custom_filter', 10, 4);
function my_custom_filter($class, $id, $align, $size) {
// Your custom filtering logic here
return $class;
}
Source Code Context
wp-includes/media.php:409
- How this hook is used in WordPress core
<?php
404 * @param int $id Attachment ID.
405 * @param string $align Part of the class name for aligning the image.
406 * @param string|int[] $size Requested image size. Can be any registered image size name, or
407 * an array of width and height values in pixels (in that order).
408 */
409 $class = apply_filters( 'get_image_tag_class', $class, $id, $align, $size );
410
411 $html = '<img src="' . esc_url( $img_src ) . '" alt="' . esc_attr( $alt ) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
412
413 /**
414 * Filters the HTML content for the image tag.
PHP Documentation
<?php
/**
* Filters the value of the attachment's image tag class attribute.
*
* @since 2.6.0
*
* @param string $class CSS class name or space-separated list of classes.
* @param int $id Attachment ID.
* @param string $align Part of the class name for aligning the image.
* @param string|int[] $size Requested image size. Can be any registered image size name, or
* an array of width and height values in pixels (in that order).
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.