Home › Forums › General Issues › 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="http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811-660x990.jpg" alt="Main Donjon (tower) of Nagoya Castle." width="660" height="990">
Where it should be something like:
<img width="2091" height="3136" src="http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811.jpg" class="attachment-full" alt="Main Donjon (tower) of Nagoya Castle." srcset="http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811-360x540.jpg 360w, http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811-660x990.jpg 660w, http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811-720x1080.jpg 720w, http://www.gojapango.com/dev/wordpress/wp-content/uploads/picture/nagoya/nagoya_castle/IMG_0811.jpg 2091w" sizes="(max-width: 2091px) 100vw, 2091px">
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);
}
The topic ‘wysiwyg and RICG Responsive Images Not working’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.