Created
February 27, 2012 19:56
-
-
Save ryanjbonnell/1926630 to your computer and use it in GitHub Desktop.
jQuery Vegas Plugin output for WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(get_field('slideshow')): ?> | |
<script src="<?php bloginfo('template_directory') ?>/js/jquery.vegas-1.2.min.js"></script> | |
<script> | |
jQuery(document).ready(function ($) { | |
$.vegas('slideshow', { | |
step: 0, | |
delay: 5000, | |
backgrounds: [ | |
<?php | |
$array = get_field('slideshow'); | |
$first_element = array_shift(array_keys($array)); | |
$last_element = end(array_keys($array)); | |
$indent = "\n\t\t\t\t\t\t"; | |
foreach ($array as $key => $value) { | |
if ($key === $first_element) { | |
echo $indent . "{ src: '" . $value[photo] . "', fade: 500 }, "; | |
} else if ($key == $last_element) { | |
echo $indent . "{ src: '" . $value[photo] . "', fade: 500 } \n"; | |
} else { | |
echo $indent . "{ src: '" . $value[photo] . "', fade: 500 }, "; | |
} | |
} | |
?> | |
], | |
preload: false | |
}); | |
}); | |
</script> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment