Question

I would like to make a image randomizer/slider that randomly displays an image from a designated gallery and has controls to view the next/previous image. I have seen this done where images must be coded into arrays, but I would like to be able to just drop images into a /img/gallery directory and have the randomizer/slider pull random images from that directory.

Could anyone offer some guidance on how to do this, possibly using jQuery, or refer me to a tutorial that does something like this?

Was it helpful?

Solution

Not a jQuery programmer but seems like you could do this:

  1. Determine the number of images in your directory (N)
  2. Choose a random number between 1 and N
  3. Load up that image and whatever else you need for the next/previous stuff

OTHER TIPS

You would need to use a server-side technology like PHP, ColdFusion, or ASP.NET to read the directory images into an array or list...

pseudocode:

Get Directory Images > Put them in an array > select random values from array
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top