Page 1 of 1

preload image in $file ?!?!?!

Posted: Thu Jul 26, 2007 7:25 pm
by Peuplarchie
Good day to you all,
Is it possible and how can I generate from a variable (which is reading trough a directory to find images) to get those images upload before the page load ?

Let say I'm using that javascript to preload image :

Code: Select all

<SCRIPT language="JavaScript">
    <!--

    if (document.images)
    {
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "http://mydomain.com/image0.gif";
      image_url[1] = "http://mydomain.com/image1.gif";
      image_url[2] = "http://mydomain.com/image2.gif";
      image_url[3] = "http://mydomain.com/image3.gif";

       var i = 0;
       for(i=0; i<=3; i++) 
         preload_image_object.src = image_url[i];
    }

    //-->
    </SCRIPT>


Thank for your help !

Posted: Thu Jul 26, 2007 7:43 pm
by Ollie Saunders
Is it possible and how can I generate from a variable (which is reading trough a directory to find images) to get those images upload before the page load ?
Please rephrase that.

Google "preload image" if you don't know how to do that.

Posted: Thu Jul 26, 2007 8:22 pm
by Peuplarchie
Ijust gived my code on this.
I have STFW, If I had found my need I wouldn't be here asking.

Thanks !

Posted: Thu Jul 26, 2007 9:33 pm
by Peuplarchie

Code: Select all

<?php
$image_counter = -1;
$row_counter = 0;
$cell_counter = 0;
$show=array('.jpg','.JPG','.gif','.GIF');
$path = 'Images/2/';


$dir_handle = @opendir($path) or die("Unable to open $path");

$image_table = "<table valign=\"top\" align=\"center\">\n<tr><th colspan=3>Existing Pics in Directory:</th></tr>\n<tr>";
while (false !== ($file = readdir($dir_handle))) {
  if(in_array(substr($file,-4,4),$show)){
        if(!(($image_counter + 1) % 3)){
          $row_counter++;
        }
$newpath0 = basename($file,".*");
      $image_table .=(($image_counter + 1) % 3)? "" : "</tr>\n<tr><td><br></td></tr><tr valign=\"top\">";
      $image_table .= "\n<td valign=\"top\"><table width=\"200\" border=\"1\" cellpadding=\"0\" cellspacing=\"1\" align=\"center\">\n";
      $image_table .= "\n<tr><td align=\"center\"><b>$newpath0</b></td></tr>\n";
      $image_table .= "\n<td><img src=\"$path$file\" width=\"200\"></td></tr>\n";
      $image_table .= "\n<tr><td></td></tr>\n";
      $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
      $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
      $image_table .= "\n<tr><td><b>Prix :</b> Test</td></tr>\n";
      $image_table .= "\n</table></td>\n";

      ++$image_counter;
      ++$cell_counter;
  }

}
$colspan= ($row_counter * 3) - $cell_counter;
$image_table .= ($cell_counter % 3) ?  "<td colspan=$colspan>&nbsp;</td>" : "";
$image_table .= "</tr>\n</table>\n";
echo "$image_table<br><br>";
echo "<b>Total Cells w pics: $cell_counter<br>";
echo "<b>Total Rows: $row_counter<br>";
echo "<b>Empty Cells in last row: $colspan";
?>

Posted: Fri Jul 27, 2007 2:19 am
by Ollie Saunders
Your post was so unclear I wasn't sure if you knew how to do a preload. I will not assist you if you are rude to me and you're still not making any sense anyway.