the_content not showing responsive image attributes srcset or sizes

I just worked out why it wasn’t working.

In order for WordPress to generate the srcset and size attributes for images in the_content, it must have a class associated with it indicating the image attachment id (for example, ‘wp-image-41’).

This is automatically attached to the image when it is inserted via the editor.

Unfortunately, in my older posts, all this class information has been stripped. Will have to go back through and re-insert the classes 🙁