apply_filters( ‘wp_get_attachment_image’, string $html, int $attachment_id, string|int[] $size, bool $icon, string[] $attr )

In this article

Filters the HTML img element representing an image attachment.


HTML img element or empty string on failure.
Image attachment ID.
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
Whether the image should be treated as an icon.
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.
  • src string
    Image attachment URL.
  • class string
    CSS class name or space-separated list of classes.
    Default attachment-$size_class size-$size_class, where $size_class is the image size being requested.
  • alt string
    Image description for the alt attribute.
  • srcset string
    The 'srcset' attribute value.
  • sizes string
    The 'sizes' attribute value.
  • loading string|false
    The 'loading' attribute value. Passing a value of false will result in the attribute being omitted for the image.
    Defaults to 'lazy', depending on wp_lazy_loading_enabled() .
  • decoding string
    The 'decoding' attribute value. Possible values are 'async' (default), 'sync', or 'auto'. Passing false or an empty string will result in the attribute being omitted.


return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr );



User Contributed Notes

You must log in before being able to contribute a note or feedback.