jquery-backstretch / jquery-backstretch

Backstretch is a simple jQuery plugin that allows you to add a dynamically-resized, slideshow-capable background image to any page or element. The image will stretch to fit the page/element, and will automatically resize as the window/element size changes.
http://www.jquery-backstretch.com
MIT License
3.91k stars 912 forks source link

Slide show change onLoad? #483

Open kmcamb opened 5 years ago

kmcamb commented 5 years ago

Is it possible to change the slide image randomly onload only instead of timed intervals?

DrkCloudStrife commented 5 years ago

You can easily do that with JavaScript. You can set all your images in an array and pick one randomly onload for backstretch.

imagesCollection = [
  '//..image1.png'
  '//..image2.png'
  '//..image3.png'
  ]
image = imagesCollection[Math.floor(Math.random() * imagesCollection.length)]
$('#hero').backstretch(image)
kmcamb commented 5 years ago

We'll give this a go. Thanks!