2nd Oct '25
/
0 comments

Limiting the Number of Images in Bricks Image Gallery Element

In the recent Bricks Image Gallery element with Image limit tutorial we showed how the built-in 'Image Gallery' element of Bricks can be duplicated and modified to only render a specific number of images. This method works regardless of the source of the images in the element - static or dynamic.

When the source is dynamic, there is a simpler way to limit the number of gallery images though - the render_tag() function in Bricks. This Pro tutorial provides the details.

Step 1

Using your favorite custom fields plugin add a field group for your post type having a field for multiple image upload/selection. Ex.: Gallery when using ACF or Image Advanced when using Meta Box.

Create/edit posts/Pages and select/upload the images for each.

Edit the Page/template with Bricks.

Add an Image Gallery element inside a Section's Container.

Click the power icon in the Images control and select your custom field. Copy the dynamic tag since we will use it in the next step (without the curly braces).

Step 2

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 613 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags:
Pro
HappyFiles Folder Images via Meta Box Taxonomy Field in Bricks Image Gallery

HappyFiles Folder Images via Meta Box Taxonomy Field in Bricks Image Gallery

How to set the source of Bricks’ Image Gallery element on a post to images in the selected HappyFiles Folder(s) via a Meta Box Taxonomy…
Adding Icon on Gallery Images in Bricks

Adding Icon on Gallery Images in Bricks

When lightbox is enabled for the images in Image Gallery element, it is probably a good idea to add a visual indicator to tell the…
Categories:
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…
Pro
Meta Box/ACF Images Staggered Grid Gallery in Bricks

Meta Box/ACF Images Staggered Grid Gallery in Bricks

Showing images from two Gallery-type of ACF or Image Advanced-type of Meta Box fields in a staggered grid layout.