Dan
Dan

Reputation: 1

Random image displayed every day

How can I display a random image on a page every day? The image will need to stay on the page for the whole day, after which it will be automatically changed to a different random image. The thing is, I have a few hundred images in a folder that could be selected to be displayed.

It would be nice if the code was JavaScript.

It's not as important but if a video could be one of the randomly selected files from the folder, that would be great!

Upvotes: -1

Views: 694

Answers (1)

ocodo
ocodo

Reputation: 30248

If this is going to be the same image for all users, you should just use a server side script to determine a random image at 12 midnight (UTC), and use that.

If it just needs to be the same all day for each user, you can do it all in JavaScript, however, you will need to provide a complete list of the images to choose from to the script.

Using a server side language, would be most effective (the alternative is a bit silly, providing the list manually.)

(Pretty much any server side language you can think of provides a simple way to get a directory listing.)

Upvotes: 0

Related Questions