Support

Account

Home Forums Add-ons Gallery Field ACF Gallery and Backstrech Reply To: ACF Gallery and Backstrech

  • AMAZING!
    Thanks a lot, I was becoming crazy trying to make it work.

    So I guess I don’t need to use anything extra to get the gallery values into the script, right?
    And could it be possible to load different image sizes depending on the device? I guess this is a question for Backstrech forum or Zurb Foundation (I use a theme based on Zurb Foundation)

    Anyway, this is the working code in case anyone wants to do something similar
    Note: This gallery field is part of a options page, and jQuery Backstrech needs to be enqueued.

    <?php  
    // Get the ACF gallery images
    
    $images = get_field('slideshow_gallery', 'option');
    ?>
    <script> 
      //Backstretch slideshow
      // Duration is the amount of time in between slides,
      // and fade is value that determines how quickly the next image will fade in
    
    $.backstretch([
    <?php
    foreach( $images as $image ) {
        echo '"' . $image['url'] . '",';
    }
    ?>
    ], {
    	duration: 3000, 
    	fade: 750
    });
    </script>