wp_get_attachment_image
Filters the HTML img element representing an image attachment.
Usage
add_filter( 'wp_get_attachment_image', 'wp_kama_get_attachment_image_filter', 10, 5 ); /** * Function for `wp_get_attachment_image` filter-hook. * * @param string $html HTML img element or empty string on failure. * @param int $attachment_id Image attachment ID. * @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). * @param bool $icon Whether the image should be treated as an icon. * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image(). * * @return string */ function wp_kama_get_attachment_image_filter( $html, $attachment_id, $size, $icon, $attr ){ // filter... return $html; }
- $html(string)
- HTML img element or empty string on failure.
- $attachment_id(int)
- Image attachment ID.
- $size(string|int[])
- Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
- $icon(true|false)
- Whether the image should be treated as an icon.
- $attr(string[])
- Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().
Changelog
Since 5.6.0 | Introduced. |
Where the hook is called
wp-includes/media.php 1176
return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr );