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 [];
}
Watch video tutorial here