4. Next we need to populate the rotate folder with images. The key here is that they must all start with the term "example", or whatever it is you named your pseudo-gif file and referenced in the .htaccess file.
The number of files included is up to you, and you can use just about any numbering scheme you want (sequential, random, single digit, multiple digits, etc). You can even have more than one file with the same number, as long as they have different extensions; example1.gif, example1.jpg, and example1.png will all be read separately.
5. At this point everything is done. The rotate folder on your server should now include the .htaccess file, the example.gif file, and as many other image files as you want to rotate.
This link is to a sample installation that mimics the text in this article (the .htaccess file is not visible, but it is there). The sample utilizes two gif, two jpg, and one png file with various numbers, some using the same number. Clicking on example.gif will load one of the other five image files. Click back on your web browser, and click example.gif again. Another image will load, and while you may randomly get the same image, keep trying it.
Notice that when you click on example.gif, the address bar of your web browser references the actual file loaded. Therefore, clicking refresh/reload when just an image has been requested will just keep loading the same image, so you have to go back and click on example.gif again to make it work. But, this simple HTML page provides an example of how this should work on a typical web page. Load that page and then click reload/refresh on your browser and the image should change with each load.
This example works well with Internet Explorer, but the way Firefox caches pages can take some of the fun away from this. Closing Firefox and opening it up to this page again will overcome that. The intention of this isn't necessarily to amuse yourself with a new image every second, but to show all the viewers online something different on subsequent visits, so even with Firefox's caching it still functions nicely.
This link is to a ZIP file that contains everything used in this article, and it may be easier to download this and make changes, than to copy and paste to start from scratch. Download it, check it out, and see what you can do with it.
As mentioned at the beginning of the article, the number of uses is rather limitless. I have used it for a signature on the Bigbruin.com phpBB forum, for banner ad rotation, and it was formerly used to load a random image of computer hardware in the header of the site.
If you start using this, or have used this for years already, please share your implementations in the forum. It would be interesting to see what other uses people can come up!
Please drop by the Bigbruin.com Forum and feel free to post any comments or questions.
|
|