Support » Developing with WordPress » What images use wp_get_attachment_image_attributes filter?

  • I’m trying to understand precisely what the purpose of wp_get_attachment_image_attributes is nowadays. From the developer reference, it seems like it ought to fire on the attributes for any <img> tag. But, from testing on my local install, it seems like it only actually works on image tags output by theme code — get_the_post_thumbnail(), wp_get_attachment_image(), and such. I’ve seen some reports like this one on WordPress StackExchange that it only works on featured images… but I’m seeing it beyond that as I said.

    What’s the official scope of this filter?

Viewing 1 replies (of 1 total)
  • Official?
    I searched the code, and the filter is only referenced in wp-includes/media.php (and several of the default themes).
    In there, it is applied in wp_get_attachment_image() as you said, but also dynamically added in order to get the wp-post-image class onto the post thumbnail.
    If you look at which functions call wp_get_attachment_image(), you’ll see 9 functions including custom logo, image widget, and gallery shortcode. https://developer.wordpress.org/reference/functions/wp_get_attachment_image/#related

Viewing 1 replies (of 1 total)
  • The topic ‘What images use wp_get_attachment_image_attributes filter?’ is closed to new replies.