Hi @Misho,
Thanks for bringing this up. I was able to find some inconsistencies with how lazy loading is detected. It was applying loading="lazy"
only to images added via an attachment ID (i.e. images added since Pro 4). I’ve made some adjustments for the next point release. Let’s see if that alleviates some of the problems you’re seeing here (once we get the release out.
For context, this is the full extent of what we are doing to enable lazy loading:
if ( $enabled && function_exists('wp_lazy_loading_enabled') && wp_lazy_loading_enabled( 'img', 'cs_apply_image_atts' ) ) {
$atts['loading'] = 'lazy';
}
We use wp_lazy_loading_enabled
to ensure the site is running WordPress 5.5 and doesn’t have filters to disable native WordPress lazy loading. If it’s allowed, we output the attribute which tells modern browsers what to do. This is run on all V2 elements when the img
tag is being generated. It doesn’t get run on text content.
Because we’re simply adding that attribute in certain cases, I’m not sure why all of a sudden we’d see incompatibilities with other lazy loading systems.
In correcting the anomalies mentioned above, I was able to find a way to retroactively add it to classic elements but I’m concerned its a bit late in the cycle to implement that. What we’re going to pursue as early as the next cycle is running all Pro output through the WordPress wp_filter_content_tags
function which will ensure lazy loading of everything, even classic images and images found in text content. Regretfully it opens up some new challenges like potentially breaking retina image output. We’ll need some more dedicated time to unpack it, but it’s definitely a priority to bring consistency to how that works.