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' );}