I like the free plugin Justified Gallery to draw a nice masonry layout. However, when I turned of lazyloading of images with Perfmatters, the once-beautiful masonry gallery breaks. All the images are the same dimension and the aspect ration gets stretched. Bleh.
Perfmatters’ excellent documentation contains the solution.
This is the same snippet from the documentation, but with the correct element to target Justified Gallery images:
// https://perfmatters.io/docs/lazy-load-wordpress/#exclude
function clc_perfmatters_lazyload_exclude_attributes($attributes) {
$attributes[] = 'data-jg-srcset';
return $attributes;
}
add_filter('perfmatters_lazyload_excluded_attributes', 'clc_perfmatters_lazyload_exclude_attributes');
I wrote this blog post to create a place on the internet that might turn up in search results if you are facing the same problem of Justified Gallery masonry images breaking with using Perfmatters lazyload.