WordPress filter hook · part of WordPress core
wp_get_attachment_image_attributes
A WordPress core filter that 19 plugins also fire themselves, running on 188K+ sites between them.
“Filters the list of attachment image attributes.”
How to use wp_get_attachment_image_attributes
It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'wp_get_attachment_image_attributes', function( $attr, $attachment, $size ) {
// Change $attr here.
return $attr;
}, 10, 3 );Argument names come from SureCart's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
19 plugins that fire wp_get_attachment_image_attributes
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
SureCart70,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size )app/src/Models/GalleryItemImageAttachment.php:246 -
RSS Aggregator by Feedzy40,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, '', '' )includes/feedzy-rss-feeds-feed-tweaks.php:89 -
Master Addons for Elementor30,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size )addons/media/ma-advanced-image/ma-advanced-image.php:1529 -
All-in-One Video Gallery20,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, NULL, $size )public/public.php:1021 -
Team10,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $fImgSize )app/Helpers/Fns.php:1560 -
ShopBuilder10,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $f_img_size )app/Helpers/Fns.php:1948 -
Media Search Enhanced5,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $post, $size )public/class-media-search-enhanced.php:394 -
Food Menu2,000+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $fImgSize )app/Helpers/Fns.php:1192 -
AMP WP600+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size )includes/components/class-amp-wp-img-component.php:257 -
Just Responsive Images500+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $this->attachment, $this->rwd_set->key )models/RwdImage.php:133 -
Gym Builder100+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $gbImgSize )inc/Controllers/Helpers/Helper.php:414 -
DocBooker90+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $wpddbImgSize )app/Controllers/Helper/Helper.php:501 -
Presswell Art Direction80+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $image, $size_key )includes/traits/trait-image-render.php:56 -
AiO Podcast Studio: All-in-One Podcast Manager, Player & Publisher10+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attributes, null, $size )public/public.php:990 -
Responsive Images10+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size )ChangeResponsiveImages.class.php:61 -
Media Search Plus10+ installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $post, $size )media-search-plus.php:231 -
GridBox Elementor WidgetsFewer than 10 installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size )includes/functions.php:205 -
Simple Video PostFewer than 10 installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, NULL, $size )public/public.php:249 -
ShareIt EasyFewer than 10 installs
apply_filters( 'wp_get_attachment_image_attributes', $attr, null, 'thumbnail' )includes/shareit-easy-content.php:91
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.