How to stop WordPress adding responsive images to your RSS feed

I have spent a lot of time hacking/munging how WordPress handles RSS output, as I often want different titles/image sizes etc. for RSS feeds than I do for the original web posts. I was just a bit unhappy to find out that WordPress’ automatic generation of responsive images (via the ‘srcset’ attributes) now adds this code to images in RSS files as well.

This is simply fixed by turning the srcset generation code off for RSS files:

if (is_feed()) {add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );}

2 thoughts on “How to stop WordPress adding responsive images to your RSS feed

What do you think?

Your email address will not be published. Required fields are marked *