Skip to content

Instantly share code, notes, and snippets.

@dkmy-sec
Last active August 17, 2017 20:27
Show Gist options
  • Save dkmy-sec/0d869fe26c638d7c455422a63006529b to your computer and use it in GitHub Desktop.
Save dkmy-sec/0d869fe26c638d7c455422a63006529b to your computer and use it in GitHub Desktop.
Backstretch JS Random Image Array For Backgrounds
jQuery(document).ready(function($) {
// Image Array Variable
var images = [
'/wp-content/themes/agency-pro/images/bg.jpg',
'/wp-content/themes/agency-pro/images/bg1.jpg',
'/wp-content/themes/agency-pro/images/bg2.jpg',
'/wp-content/themes/agency-pro/images/bg3.jpg',
'/wp-content/themes/agency-pro/images/bg4.jpg',
'/wp-content/themes/agency-pro/images/bg5.jpg',
'/wp-content/themes/agency-pro/images/bg6.jpg',
'/wp-content/themes/agency-pro/images/bg7.jpg',
];
// Function to Shuffle through the Array Randomly
var slideshow = images.sort(function() { return 0.5 - Math.random() });
// Displays a Random Image to begin the slideshow and randomizes the slideshow.
$("body").backstretch(slideshow,
{
duration:6000,
fade:4000,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment