Okay, this has been bugging me. I've been making some changes to a client's site, and I'm trying out a little time-saver... since it would take me years to manually change it.
Firstly, here's the HTML for an image used hundreds of times throughout the site:
Code:
<img src="images/no_image.gif" />
I've changed the .htaccess file to redirect the image to a PHP file called 'randImg.php' like so:
Code:
RewriteEngine on
RewriteRule ^images/no_image.gif$ randImg.php
My 'randImg.php' uses GD to output one of four new random images:
Code:
<?PHP
header("Content-type: image/png");
$temp = rand(1,4);
$path = "images/myauction/fish".$temp.".png";
$i = imagecreatefrompng($path);
imagepng($i);
imagedestroy($i);
?>
Firstly, this pretty much works (shocker I know... at least it was for me). Every time I refresh the page, I get 1 of the 4 images randomly.
HOWEVER... If there is more than one of these 'no_image.gif's on each page, it displays the same image for each of them.
I thought it might have something to do with the browser assuming each image will be the same, but I don't know how to get round this.
Not sure where to go... any help greatly appreciated. 
__________________
itsCooper
|