I've distilled this example down to its most basic functionality on my local site and it still has no effect, no matter which attribute I choose to change.
Here is the developer page for the filter, with a couple of examples. There's also a working example inside functions.php in the TwentySixteen theme. I've read a few examples on this stack as well, and by all accounts this should work but it just doesn't change the attribute:
function developing_filter_img_attr( $attr ) {
$attr['class'] = "none";
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'developing_filter_img_attr' );
Am I missing something? Is it a priority issue? I have a few other filters within my functions file, all dealing with images and their attributes, and they've all worked correctly and continue to work correctly. They include:
- intermediate_image_sizes_advanced
- max_srcset_image_width
- wp_calculate_image_sizes
sizes
attribute on certain conditions, but when I inspect the images, these custom attributes aren't showing. I think they're still using the default WPsizes
setting.