1

I cannot find a way to generate srcset for images added inside Wysiwyg Editor field of Advanced Custom Field (ACF) plugin. Obviously, i know how to generate WordPress image srcset using:

wp_get_attachment_image_srcset($attachment_id);

function, as described at WordPress codex: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_srcset/

But my real problem is to figure out most efficient way to get image srcset for images added inside ACF Wysiwyg Editor as the way my website is structured there is too much content inside my Wysiwyg Editor like text, images, videos and different heading tags.

Also, all the images added inside WordPress default Wysiwyg Editor is showing image srcset properly.

It's just that ACF Wysiwyg Editor is not supporting this. Any pointers to add efficient filter/hooks will be really helpful.

closed as off-topic by Tom J Nowell Jul 27 '18 at 2:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • You're going to need a hefty dose of ACF knowledge here, or a feature request to the ACF developers – Tom J Nowell Jul 27 '18 at 2:51
  • Voted to reopen. srcsets for image tags are added with a filter on the_content. Doing this on arbitrary HTML is possible with the wp_make_content_images_responsive() function and has nothing to do with ACF. – Jacob Peattie Jul 27 '18 at 4:04
  • Thanks Jacob, the function just worked perfectly and has solved my issue – Vatsh Patel Jul 27 '18 at 6:01