First step is to add Custom Options to Query Tipe using WP hook bricks/setup/control_options like:

add_filter('bricks/setup/control_options', function($control_options) {
    $control_options['queryTypes']['product_gallery'] = esc_html__('Product Image List', 'my-bricks');
    return $control_options;
});

We need to return a custom query result, using bricks/query/run. The callback function receives the query results and the query object. It first checks if the object type in the query matches ‘product_gallery’. If it does, it retrieves the current WooCommerce product. It then constructs an array of results containing information about the product’s featured image, variations (if any), and gallery images. Finally, it returns the modified results array.

add_filter('bricks/query/run', function($results, $query_obj) {
    if ($query_obj->object_type !== 'product_gallery') {
        return $results;
    }

    // Get the current WooCommerce product
    global $product;

    // Check if we are on a single product page and if the product exists
    if (is_a($product, 'WC_Product')) {
        $product_id = $product->get_id();

        // Get the product's featured image
        $featured_image_id = $product->get_image_id();
        $featured_image_url = wp_get_attachment_image_url($featured_image_id, 'full');
        // Replace 'full' with desired image size

        // Prepare the result array with the featured image
        $results = array();
        $results[] = array(
            'id' => $featured_image_id,
            'name' => get_the_title($product_id),
            'image' => $featured_image_url,
        );

        // Handle variable product variations
        if ($product->is_type('variable')) {
            // Get the product's variations
            $variations = $product->get_available_variations();

            // Loop through the variations and add their images to the result array
            foreach ($variations as $variation) {
                $variation_id = $variation['variation_id'];
                $variation_product = wc_get_product($variation_id);
                $variation_image_id = $variation_product->get_image_id();
                $variation_image_url = wp_get_attachment_image_url($variation_image_id, 'full');
                // Replace 'full' with desired image size

                $results[] = array(
                    'id' => $variation_image_id,
                    'name' => get_the_title($variation_id),
                    'image' => $variation_image_url,
                );
            }
        } elseif ($product->is_type('simple')) {
            // For simple products, just add the featured image once (already added above).
            // You can add additional handling here if needed.
        }

        // Get the product gallery images
        $product_gallery = $product->get_gallery_image_ids();

        // Loop through the gallery images and add them to the result array
        foreach ($product_gallery as $attachment_id) {
            $gallery_image_url = wp_get_attachment_image_url($attachment_id, 'full');
            // Replace 'full' with desired image size

            $results[] = array(
                'id' => $attachment_id,
                'name' => get_the_title($attachment_id), // You can use the image title if you want
                'image' => $gallery_image_url,
            );
        }
    }

    return $results;
}, 10, 2);

Then we need to retrieves a specific property from the loop object using the provided property name. It first gets the loop object using \Bricks\Query::get_loop_object(). If the loop object doesn’t exist or is not an array, or if the specified property doesn’t exist in the loop object, it returns false. Otherwise, it returns the value of the specified property from the loop object.

add_filter('bricks/query/loop_object', function($loop_object, $loop_key, $query_obj) {
    if ($query_obj->object_type !== 'product_gallery') {
        return $loop_object;
    }
    // This filter doesn't require any changes for this example
    return $loop_object;
}, 10, 3);

function get_product_images_url($name) {
    $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;
    return $loop_object[$name];
}

Function names must pass the check through the bricks/code/echo_function_names filter. So see this post to do that.

Next step is to create Nestable Slider element in Bricks Builder canvas editor. Enable Query Type and add image element. The URL of image element would be use