Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005

<?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

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
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.

Llanilek

Llanilek Avatar
Former Elite Mod

****
Dedicated Studio Member

931


October 2005
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

newBookmarkLockedFalling