• Skip to main content

Copper Leaf Creative

WordPress Website Design and Development

Working With Us

Are We a Good Fit?

Roadmapping

Development Process

Pricing

Our Work

Portfolio

Testimonials

Us

Team

Videos

We Believe

Company Info

Make a Payment

Let’s Chat

Justified Gallery vs. Permatters lazyload – FIXED

September 5, 2014 by Gordon Seirup

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.

Filed Under: Resources / Reference

Copyright © 2023 Copper Leaf Creative | 446 E. 29th St., #2012, Loveland, CO | (970) 776-8778 | Privacy | Terms

Have you heard our ads for Together Financial?