Filters the HTML img element representing an image attachment.
Parameters
$htmlstring- HTML img element or empty string on failure.
$attachment_idint- Image attachment ID.
$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).
$iconbool- Whether the image should be treated as an icon.
$attrstring[]- Array of attribute values for the image markup, keyed by attribute name.
See wp_get_attachment_image() .More Arguments from wp_get_attachment_image( … $attr )
Attributes for the image markup.
srcstringImage attachment URL.classstringCSS class name or space-separated list of classes.
Defaultattachment-$size_class size-$size_class, where$size_classis the image size being requested.altstringImage description for the alt attribute.srcsetstringThe'srcset'attribute value.sizesstringThe'sizes'attribute value.loadingstring|falseThe'loading'attribute value. Passing a value of false will result in the attribute being omitted for the image.
Default determined by wp_get_loading_optimization_attributes().decodingstringThe'decoding'attribute value. Possible values are'async'(default),'sync', or'auto'. Passing false or an empty string will result in the attribute being omitted.fetchprioritystringThe'fetchpriority'attribute value, whetherhigh,low, orauto.
Default determined by wp_get_loading_optimization_attributes().
Source
return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr );
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.