I am looking for a good script to rotate an image with a static URL to change every time you refresh the page. This is for a signature system btw. <img src="http://domain.com/img1.jpg /> Code (markup): So the file img1.jpg will have a new image associated with it. I do not want the HTML to change at all, just that the actuall file is governed by a Php script. I heard somewhere there is a way to have the the image file a .php file... is there a way to do this?
make a folder named img1.jpg place images in it put an index.php file in it: <?php $pictures = array("picture.jpg","picture2.jpg","picture3.jpg"); header("Content-type: image/jpg"); echo file_get_contents($pictures[rand(0,(count($pictures)-1))]); ?> there
a simple php script for your code <img src="http://yourdomain.com/images/rotate<?php echo(rand(1,5)); ?>.jpg" /> make sure, you have file with named: rotate1.jpg rotate2.jpg rotate3.jpg rotate4.jpg rotate5.jpg I think you'll get the idea
There's a lot of ways to do it. What your ideal way of managing which images are used in the rotation is a big factor in which one would be best for you. I would try to get Apache & mod_rewrite to do as much of the leg work as possible, but that might just be me. For instance if I had 10 images in a "signatures" folder I might use something like this in my htaccess to rewrite requests to "sig.jpg" to one of the 10 sigs named "0.jpg" through "9.jpg" using a 302 Temporary redirect so the browser will keep checking and getting redirected. RewriteEngine On RewriteCond %{TIME_SEC} ([1-9])$ RewriteRule sig\.jpg$ signatures/%1.jpg [R=302,L] Code (markup):