How can I display a new background image on each page refresh on a website (using WordPress if this helps anything)? I would also like to take into account different screen resolutions, and proper handling for this. Any help would be greatly appreciated.
Leave a Reply
You must be logged in to post a comment.
Have you seen this page in the wordpress codex?
It explains how to rotate the header image. It shouldn’t be too hard adapt it for your needs.
Just have your own script that randomly returns pictures each time it is accessed. I have one that I wrote in C at the URL below that returns a different pic each time.
http://www.scale18.com/cgi-bin/gpic
You can generate it in realtime with GD library
To detect screen resolution, you can use client-side javascript
To display a different image, you could probably use a script to generate a random number and display the image that ties to it…?
You could store the “current” imaage in the session and just check each time you generate a new random number, that it’s not going to display the last….
This is what I use with WordPress to randomly rotate the header images on my site.
Someone else wrote the code and I can’t remember who. Put the php code below into a file named rotate.php, and then put rotate.php into the directory of images that are to be rotated (i.e. “headerimages”), and rotate.php will draw from them. Call rotate.php from your CSS style sheet in whatever DIV is used for your headerimage.
I don’t understand what you mean by being able to handle different screen resolutions. End user screen resolutions?
JavaScript is probably your best bet for this one.