Outputting Advanced Custom Fields image with srcset, sizes, alt text & title

This is a slight update of my original post this takes it a step further and makes the whole process a little more dynamic, this should also return everything you need to match the ‘default’ behaviour within WordPress for any embedded images.

This will output any ACF image including all the srcset attributes, Ssize attributes, qlt text & title that is attached to an image within WordPress’s Meta Boxes.

When setting up your ACF Custom Field for your image make sure you set the image field to return as ID rather than array otherwise the below snippet won’t work.

Code Example:

It took me nearly a day to get this working properly, I hope this snippet helps somebody out.