How to make an image randomizer from gallery directory? [closed]
-
20-09-2019 - |
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?
Solution
Not a jQuery programmer but seems like you could do this:
- Determine the number of images in your directory (N)
- Choose a random number between 1 and N
- 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