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>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.