NO BUG: Nestable Slider with dynamic image (gallery)

Browser: Chrome 110
OS: macOS / Windows / Linux / etc.
URL: Link to a page that illustrates this issue

Hey there!!! I don’t know if is bug or feature request or i make something wrong. I am trying to add custom field gallery into the post. Then inside the post i use nestable slider, inside this nest i want to loop over the gallery of my custom field, and show one image of my gallery on each slider. Is that possible? Thank you. (V1.8.2)

1 Like

This thread might help: Media query and Nestable slider (acf/ JetEngine gallery field) - #4 by aslotta

1 Like

Hey,
It is currently not possible to query gallery fields within the nestable slider via the interface. However, the link Martin shared should help (thanks Martin!).

1 Like

thank you so much for helping me, still not able even with these codes to make it work. Really appreciate your time.

Are you using an acf gallery field? If so I can post how it works tomorrow once I’m back at my pc.

i made it work, but i can’t make it work properly, because i am trying to use it on specific post type and category. For now just get all the media i have uploaded for a reason :confused: @manc yes i use acf

Post some screenshots of your setup (acf field, query loop, code) and I’ll try my best to figure it out tomorrow. No guarantees haha but it worked for me so should be able to find the culprit

1 Like

THanks so much for helping me!!
Code (same as yours with my element id)

add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
    if ( $element_id === 'brxe-rmpcwq' && function_exists( 'get_field' ) ) {
        $gallery = get_field( 'gallery' );
        if ( empty( $gallery ) ) {
            /* Make sure that no posts are returned when
             * there are no images in the gallery
             */
            $query_vars['post__in'] = [0];
            return $query_vars;
        }
        
        /* Get the first gallery item to automatically determine
         * the ACF gallery field's return format
         */
        $test_item = current( $gallery );
        if ( is_array( $test_item ) ) {
            // Get image IDs from image arrays
            $gallery = array_map( function( $image_array ) {
                return $image_array['ID'];
            }, $gallery );
        } else if ( is_string( $test_item ) ) {
            // Try to get image IDs from image urls
            $gallery = array_map( function( $image_url ) {
                return attachment_url_to_postid( $image_url );
            }, $gallery );
        }
        
        $query_vars['post__in'] = $gallery;
    }
    
    return $query_vars;
}, 10, 3 );

I have a template(registered as Section) with query Loop
Query


Elements

Acf fields

Acf rules

Thank you so much!!

Try removing brxe- from the ID in your code snippet. The internal ID used by bricks removes that prefix. Got stumped by this as well the first time, if it still doesn’t work, I’ll take a look with fresh eyes tomorrow. Also the acf gallery is set to return ID right? Can’t remember if that made a difference.

1 Like

Not working unfortunately, after removing brxe- not even got images back. @manc acf by default returns array

Hey @millerose,

if you can provide me with some temporary credentials to your site and tell me where exactly I find the relevant items I’m happy to have a look.

Best,

André

Hmm comparing with mine, it looks correct. If you check in the inspector, are empty divs created for each slide even if no images are shown?

Here is my working setup (only thing I couldn’t see from your setup is how you setup the image element itself):

Snippet:


add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
    if ( $element_id === 'njhusk' && function_exists( 'get_field' ) ) {
        $gallery = get_field( 'galerie' );
        if ( empty( $gallery ) ) {
            /* Make sure that no posts are returned when
             * there are no images in the gallery
             */
            $query_vars['post__in'] = [0];
            return $query_vars;
        }
        
        /* Get the first gallery item to automatically determine
         * the ACF gallery field's return format
         */
        $test_item = current( $gallery );
        if ( is_array( $test_item ) ) {
            // Get image IDs from image arrays
            $gallery = array_map( function( $image_array ) {
                return $image_array['ID'];
            }, $gallery );
        } else if ( is_string( $test_item ) ) {
            // Try to get image IDs from image urls
            $gallery = array_map( function( $image_url ) {
                return attachment_url_to_postid( $image_url );
            }, $gallery );
        }
        
        $query_vars['post__in'] = $gallery;
    }
    
    return $query_vars;
}, 10, 3 );

Loop:
image

Image inside loop:
image

ACF Gallery

Hey there!!! Yes code is working great, @aslotta helped me a lot on the setup too!!! Thank you so much all of you for your time!!!

@millerose I’m having the exact issue you were! Do you or @aslotta remember how this issue was resolved? I’ve added the snippet for the acf gallery and gone over all the settings in the builder but it’s still showing everything I’ve uploaded to the media instead of the acf gallery. I’ve looked at everything over and over… not sure what I’m missing. :confused:

Hey there, you are lucky because i reused this fanction before a week and I had the same problem as you, at the end, I used a free plugin “Pods” and used a shortcode to apply the gallery, really ways easier instead of trying this.
check this post will really help, scroll to the last reply from yakman. I hope this help you.

1 Like

Thanks! Really appreciate it, this is definitely helpful–I think I’ll be able to make this work.

1 Like