Home Forums General Issues wysiwyg and RICG Responsive Images Not working


wysiwyg and RICG Responsive Images Not working

  • I suspect this is more an issue with wordpress tinyMCE content Editor rather than ACF.

    If an image is inserted into WYSIWYG section, via the Add Media button, of ACF it does not add the RICG Responsive Image code.

    <img class="aligncenter size-large wp-image-4966" src="" alt="Main Donjon (tower) of Nagoya Castle." width="660" height="990">

    Where it should be something like:
    <img width="2091" height="3136" src="" class="attachment-full" alt="Main Donjon (tower) of Nagoya Castle." srcset=" 360w, 660w, 720w, 2091w" sizes="(max-width: 2091px) 100vw, 2091px">

    Sample Page

    Why is this a problem?

    The RICG Responsive Images plugin is going to made part of the WP core in December 2015 with release 4.4.

    If you have any ideas where the problem actually lies, please let me know, so it might be fixed prior to the release of 4.4.

  • Did some testing, I thought the srcset might be added when the image was inserted into the editor, but it appears that it’s not added until the content is displayed on the front end.

    I’m assuming that the pluging modifies the content when the_content hook runs. ACF does not cause this hook to run and instead uses acf_the_content

    Try adding the following into your functions php file, this is copied from the responsive images plugin.

    add_filter('acf_the_content', 'tevkori_filter_content_images', 5, 1 );

  • WOW!

    I wasn’t expecting you to solve the problem, so thank you.

    And thank you even more so for such a fast response.

  • I doubt this is something that will be added to ACF since it’s a compatibility problem with another plugin, that’s part of what I do, solve problems. this was actually a fairly easy one. I had a feeling that the responsive image plugin was filtering the_content even before I looked and I know that ACF does not use the_content on wysisyg fields. I’m assuming that if WP adds this to core that they’ll add this to part of the content filters like autop and the like and then the developer of ACF will probably add it to ACF. So you’ll need to look out for the potential of having images filtered twice at some point I guess.

    I suppose it should be done so that potential errors can be avoided.

    if (function_exists('tevkori_filter_content_images')) {
        add_filter('acf_the_content', 'tevkori_filter_content_images', 5, 1);
  • Great. Thanks for the heads up on that.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘wysiwyg and RICG Responsive Images Not working’ is closed to new replies.