2nd Feb '26
/
0 comments

How to add a Class to all Images in Bricks Galleries

Images output by Bricks Gallery have these classes by default (generally):

image bricks-lazy-load-isotope bricks-layout-inner css-filter

When using Perfmatters' Lazy Loading, Gallery images will collapse into each other.

Targeting the Gallery images using the default classes is not a good idea because they are generic.

This Pro tutorial shows how the bricks/element/settings filter can be used to add a custom class of bricks-gallery-image to fix the above problem.

After adding the PHP code and specifying our custom class (w/o the dot at the front) in Perfmatters' settings,

:

After implementing the tutorial, Gallery images will have these classes in the frontend:

image bricks-lazy-load-isotope bricks-layout-inner css-filter bricks-gallery-image

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 633 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to create filters with IsotopeJS in Bricks (Part 2): Dynamic Image Galleries

How to create filters with IsotopeJS in Bricks (Part 2): Dynamic Image Galleries

This tutorial series will review how to create a dynamic filterable image gallery using the IsotopeJS library‘s features in Bricks. Requirements Create a custom taxonomy for your…
Term-specific single post template in Bricks

Term-specific single post template in Bricks

Updated on 25 Jun 2025 In Reddit a user asks: Template conditional logic to exclude pages with a particular taxonomy term? I can't figure out…
Pro
ACF Relationship Select Filter in Bricks

ACF Relationship Select Filter in Bricks

In the BricksLabs Facebook group, a user asks: I'm learning about ACF relationships and attempting to output a list of posts on any given page,…
Categories: