An astute reader writes:
I noticed that the <img src> tag for your rotating header points at a PHP script.
First, the last part:
The second rule of Hivelogic is: Okay, use it sometimes, but only when you have no other choice and you know your users will be able to support it, and do so in the most cross-browser-compliant way you can, which is almost impossible, so refer to Rule #1.
Lastly, the first part:
How do you use PHP to deliver a random rotating image? It’s quite simple: Toss a bunch of images (either .gif or .jpg for now), all the same height and width (or they’ll be scaled and stretched by the browser, which looks terrible) into a folder somewhere. Feel free to add or remove images from the folder at any time. The script will pick randomly from whatever it finds.
Now you’ll use PHP to get a list of files in the folder you’ve specified, randomly select one of them, and stream it (prefaced by the file’s content-type) to the browser. Just paste this PHP code (or download it) into a file with a .php extension and save it somewhere:
$fileList = array();
$folder = "folder_where_you_put_the_images";
$handle = opendir($folder);
false !== ( $file = readdir($handle) )
substr($file, -4) == ".gif" ||
substr($file, -4) == ".jpg"
$fileList[count($fileList)] = $file;
$randNum = rand( 0, (sizeOf($fileList) -1) );
substr($fileList[$randNum], -4) == ".gif"
header ("Content-type: image/gif");
} elseif (
substr($fileList[$randNum], -4) == ".jpg"
header ("Content-type: image/jpeg");
To keep things simple, you often put the .php file in the same folder as the images, and set $folder = “.” (which means “I’ve got your images right here, buddy”).