For the complete documentation index, see llms.txt. This page is also available as Markdown.

Gallery field render options

By default, Advanced Views displays the Gallery field using a row of <img> tags. You can customize the Layout template to change how it's rendered:

Example of the Grid, taken from our ACF Gallery article.

The CSS grid feature is the easiest way to display Gallery images in a grid.

The example code below shows how to set this up. Change '2' to your desired number of columns in the grid-template-columns rule, and adjust the gap, which controls the space between items, from 20px to your preferred value:

Twig template:

CSS code:

From the Gallery layout dropdown, select the Classic or Flat masonry option and press the Update button.

The Classic masonry employs the Macy.js, while Flat uses a Flat Masonry script from Lightsource.

Pro tip: You can apply both Masonry and Lightbox to the same gallery field simultaneously to provide a visually appealing preview and allow for a detailed display on click.

Optional: After saving, switch to the CSS & JS tab, and fine-tune the instance settings:

Macy.js

Example of the Macy.js, taken from our ACF Gallery article.

In the Masonry instance settings, you can fine-tune the number of columns, the gap between items (margin), and the responsive behavior. Check the Macy.js documentation to learn more.

Flat Layout

Example of the Flat masonry, taken from our ACF Gallery article.

The flat masonry is a simple script, which offers only the basic settings, including gap between items and min-row height:

Example of the Inlline-Carousel, taken from our ACF Gallery article.

From the Gallery layout dropdown, select the Inline-Gallery option and press the Update button.

The Inline-Gallery option employs the Carousel feature of the LightGallery library.

Optional: After saving, switch to the CSS & JS tab, and fine-tune the instance settings:

Example of the images slider, taken from our ACF Gallery article.

From the Enable slider dropdown, select the Splide option and press Update. This option employs the Splide library, with the following defaults:

Displaying captions

In your Layout, copy the Default template content into the Custom template field and modify it as per the example below, by adding the image_item.caption usage:

Twig example:

Key Details

  • Caption Source: The {{ image_item.caption }} tag pulls from WordPress’s native caption field (set in the media library).

  • Splide Structure: The outer wrapper must still keep Splide’s structure:

    • div.splide > div.splide__track > ul.splide__list > li.splide__slide

  • Conditional Caption: Only renders the <div class="caption"> if a caption exists.

Caption Styling (Optional)

You can style the caption by adding this CSS to your Layout:

Example of the lightbox, taken from our ACF Gallery article.

Lightbox shows a zoom icon on image hover and allows readers to click and open an image in full-screen mode and switch between items if there are others.

Pro tip: You can apply both Masonry and Lightbox to the same gallery field simultaneously to provide a visually appealing preview and allow for a detailed display on click.

From the Enable lightbox dropdown, select the LightGallery or Simple (no settings) option and press Update. The LightGallery option employs the LightGallery library, and has the following defaults:

6. FAQs

Masonry last image stretching

How to fix it using CSS overrides

Copy the following CSS snippet into your Layouts' -> CSS & JS Tab -> CSS Code field.

Last updated