This is a simple image preloading script I created in PHP for my own site. It basically reads the media file types of your choice, from a folder that you specify into an array.
The benefit this small script has for me is that I can add or remove images from my media folder and not have to update my HTML code...!
<?php function loadMedia($directory) { $thumbnail = ''; { while(false !== ($thumbnail = $handle->read())) { { $thumbnails[] = "'/$directory$thumbnail'"; } } $handle->close(); } return $thumbnails; } $preloaded = $thumbnail = ''; $thumbnails = loadMedia('media/'); foreach($thumbnails as $image) { $thumbnail .= $image.','; } ?> <body onload="javascript:MM_preloadImages(<?php echo $preloaded; ?>);">