add_filter( 'bricks/setup/control_options', function( $control_options ) {
$control_options['queryTypes']['gallery_field'] = esc_html__( 'Single Product Image List', 'my-plugin' );
return $control_options;
} );
add_filter( 'bricks/query/run', function( $results, $query_obj ) {
if ( $query_obj->object_type !== 'gallery_field' ) {
return $results;
}
// Get the product gallery images from ACF gallery field
$portfolio_gallery = get_field('portfolio_gallery', $product_id);
// Check if the gallery field has images
if( $portfolio_gallery && is_array($portfolio_gallery) ) {
// Loop through the gallery images and add them to the result array
foreach ( $portfolio_gallery as $image ) {
$gallery_image_id = $image['ID'];
$gallery_image_url = $image['url']; // Assuming you want the URL of the image
$gallery_image_caption = $image['caption']; // Assuming 'caption' is the ACF field name for captions
$results[] = array(
'id' => $gallery_image_id,
'name' => get_the_title( $gallery_image_id ), // You can use the image title if you want
'caption' => $gallery_image_caption, // You can add any other data related to the gallery image here
'image' => $gallery_image_id,
);
}
}
return $results;
}, 10, 2 );
add_filter( 'bricks/query/loop_object', function( $loop_object, $loop_key, $query_obj ) {
if ( $query_obj->object_type !== 'gallery_field' ) {
return $loop_object;
}
// This filter doesn't require any changes for this example
return $loop_object;
}, 10, 3 );
function get_gallery_image_data($name, $image_size = 'full') {
$loop_object = \Bricks\Query::get_loop_object();
if (!$loop_object) return false;
if (!is_array($loop_object)) return false;
if (!array_key_exists($name, $loop_object)) return false;
// Check if the property is 'image' and if so, append the size parameter
if ($name === 'image') {
$image_id = $loop_object[$name];
$image_url = wp_get_attachment_image_url($image_id, $image_size);
return $image_url;
}
return $loop_object[$name];
}
UPDATE 25 May 2024
There is new simple method to query ACF Gallery Field in Bricks Builder. You can choose Query Editor in Query Option.
/* use gallery field id from ACF */
$acf_images = get_field("my_gallery");
/* in case you want to use ACF Option field */
// $acf_images = get_field("my_gallery", "option");
if (!empty($acf_images)) {
return [
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'orderby' => 'post__in',
'post__in' => $acf_images,
'posts_per_page' => -1,
];
} else {
return [];
}
And make sure to set “ImageID” as the Return Format for the ACF Gallery Field. Thanks to MartinWB for the original code!
Additional info 9 June 2024
If you need to sync the thumbnail and main slider use this javascript code below:
<script>
document.addEventListener('DOMContentLoaded', function () {
setTimeout(() => {
const main = window.bricksData?.splideInstances['zqxtis']; // Main slider id
const thumbnail = window.bricksData?.splideInstances['zjxtwh']; // Thumbnail SLider ID
if (main && thumbnail) {
main.sync(thumbnail);
}
}, 250);
});
</script>UPDATE JULY 2025
For displaying POD galery field, use this code in query editor:
// Get the Pods 'galeri' field
$galeri = pods_field('galeri');
$pod_images = [];
// If it's an array (of image data), extract the IDs
if (is_array($galeri)) {
$pod_images = array_map(function($item) {
return $item['ID'];
}, $galeri);
// Optional: echo the IDs as comma-separated string (for debug)
// echo implode(', ', $pod_images);
}
// If the result is not empty, return args for WP_Query
if (!empty($pod_images)) {
return [
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'orderby' => 'post__in',
'post__in' => $pod_images,
'posts_per_page' => -1,
];
} else {
return [];
}

10 comments
malenabravvo
Hi Ivan!
I need to adapt this method to Pods and I don’t seem to get it right. Do you know if it is possible to make it work? I am not a developer, so I might be making a basic mistake I am not aware of. Thank you in advance 🙂
Ivan Nugraha
TBH, i havent tried pods yet. Would you mind to let me know the setup of pods you work on?
malenabravvo
Hi! thank you for your response 🙂 I have a very simple setup: Pod called ‘post’ (Custom Post Type – extended) with a group named ‘more_fields’ containing a field named ‘gallery’ (field type: file/image/video) with no file upload limits.
Ivan Nugraha
Hi, i updated the article. Please try it 😀
malenabravvo
Hi! Sorry, I didn’t see your reply! Thank you so much for giving it a try! I’ve tried to make it work but it doesn’t seem to be reaching the images correctly, I don’t know if something about the configuration of pods media fields works differently.
malenabravvo
Hi! I couldnt figure out what the problem was, so I asked reddit and got to a solution. Here’s the discussion in case anyone is interested: https://www.reddit.com/r/BricksBuilder/comments/1mo4uki/pods_gallery_query_loop/
vincentczb
Hey Ivan,
Is it possible adding video into acf gallery and show it in the bricks slider and thumb? I found this: https://support.advancedcustomfields.com/forums/topic/add-videos-on-acf-gallery/ but can not make it happen.
Ivan Nugraha
Hi vincent, I havent tried it yet but I do think so. What is your setup for the fields?
jungwahdika
Hi Ivan,
How do we access the Gallery field type if it was inside a repeater field?
thank you!
jungwahdika
apologize, pressing send to early 🙁
for further context, the custom field and the cpt are created with JetEngine