|
<?php
// Image Preloader Class
class imagePreloader { function load_images() { echo "<div style=\"display:none;\" id='hiddenimg'>";
$dir = $_SERVER['DOCUMENT_ROOT']; // Find out the directory the script is running from
$d = $dir."/images/"; // add your images directory, so the script knows where to look [change as needed]
$r_dir = opendir($d); // Open the images directory ready to be read.
while ($f = readdir($r_dir)) { $size = getimagesize("images/$f"); // extract file size
echo "<img src=\"images/$f\" $size[3] >"; // print file name } echo "</div>"; } function display_images() { echo "<script type='text/javascript'>"; echo "document.getElementById('hiddenimg').style.display = '';"; echo "</script>"; }
}
$test = new imagePreloader;
echo $test->load_images(); echo $test->display_images(); ?>
Last Edit: Oct 16, 2006 13:02:54 GMT by Llanilek
|
|
|
|
|
Maybe you should check it for parse errors at least. And test it too.
$size = getimagesize("images/$f); // extract file size
Missing a quote after $f.
|
|
|
|
|
ok tested.. i've added a beta function there the display images it causes warnings if it can't get access to all the files in the selected directory which i am working on but the preloader works
|
|
|
|