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

Related Tutorials..

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.
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…
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
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
Dynamic HappyFiles Gallery in Bricks with Meta Box or ACF Pro

Dynamic HappyFiles Gallery in Bricks with Meta Box or ACF Pro

Updated on 12 Jul 2023 This Pro tutorial provides the steps to show the images uploaded to an "Image Advanced" type of custom field created…
Categories:
Pro
Random images from ACF Options Gallery in Bricks

Random images from ACF Options Gallery in Bricks

This Pro tutorial provides the steps to output images from an ACF Gallery-type custom field in a Bricks query loop randomly with each image appearing…
Categories:
Pro
Configuring Image Gallery dynamic source in Bricks

Configuring Image Gallery dynamic source in Bricks

Let's say you have a custom field created with ACF Pro of the type Gallery called "Property Gallery" for posts of "Property" CPT. In the…