Topic: Preload Image Problem

On my sites I usually preload my images with JavaScript.  Since the image paths in this setup are encoded and go through image.php, it doesn't really work with my script, which needs a name, exact sizes, and a path.

Any ideas on how to incorporate an image preload function with this code?

Re: Preload Image Problem

I really haven't been asked about preloading images before... does that improve the user experience enough to offset the load on the server by requesting all images?
If you give me an idea how the preloading works I can probably clunk something out smile

Patrick
Lead developer FreeRealty
Other claims to fame: http://www.rwcinc.net
Enrolled Agent, Licensed to Represent Taxpayers before Exams, Appeals and Conference divisions of the Internal Revenue Service.

Re: Preload Image Problem

I've only used javascript (below) on primary pages, and I think all it does is load the images into the cache, so as the user hits secondary pages the images don't have to load.  I think it's very helpful, especially for those of us that still have dialup.  The images load in the background, so there's a progress bar at the bottom, but you can be looking at the primary page while it's happening.

<script type="text/javascript">

Image1 = new Image(1650,106)
Image1.src = "images/back-papers.jpg"

Image2 = new Image(288,288)
Image2.src = "images/blah.jpg"

// End Hiding -->

Re: Preload Image Problem

I think you can do this by pulling the image names into an array - if you are using folders to save your images. I'm not sure if it can be done using the database to store images. I will look at it again today and see if I have a solution.

Patrick
Lead developer FreeRealty
Other claims to fame: http://www.rwcinc.net
Enrolled Agent, Licensed to Represent Taxpayers before Exams, Appeals and Conference divisions of the Internal Revenue Service.

Re: Preload Image Problem

After looking at all the pages that are used to display images, I'm not sure that it can be done without a rewrite of image.php. It may be fairly simple, but I think you will lose the possibility of switching to using images from the database due to the way that image.php displays the actual image. It reads the binary file and then spits it out onto the screen.

Do you know if the preload script can call image.php as it's written? That's the only way that I see this working without rewriting at least a portion of the underlying scripts.

Patrick
Lead developer FreeRealty
Other claims to fame: http://www.rwcinc.net
Enrolled Agent, Licensed to Represent Taxpayers before Exams, Appeals and Conference divisions of the Internal Revenue Service.

Re: Preload Image Problem

Ok... I think that I have a solution.
Edit propview.php.
Uncomment line 112
This:

//  $listimages = mysql_fetch_array($images);

changes to this:

 
  $listimages = mysql_fetch_array($images);

Then.... about line 163 change:

 alt=\"Click to Enlarge\" /></a>  ";
   $count++;

  }

to something like:

 alt=\"Click to Enlarge\" /></a>  ";
 echo "<script type=\"text/javascript\">
      loader[$count] = new Image();
        loader[$count].src = image.php?Id=$listimages[$count];
      </script>";

   $count++;

  }

This was propview:
$Id: propview.php,v 2.9.2.18 2006/01/23 01:18:54 pat Exp $
hmm.... the version in the release looks like  propview.php,v 2.9.2.15

You can do the same thing in propview,v 2.9.2.18 except it's line 125 and 172.

Patrick
Lead developer FreeRealty
Other claims to fame: http://www.rwcinc.net
Enrolled Agent, Licensed to Represent Taxpayers before Exams, Appeals and Conference divisions of the Internal Revenue Service.

Re: Preload Image Problem

Actually,
that doesn't look like it does what I thought it did. It doesn't seem to be any faster loading the image the first time. A little more work big_smile

Patrick
Lead developer FreeRealty
Other claims to fame: http://www.rwcinc.net
Enrolled Agent, Licensed to Represent Taxpayers before Exams, Appeals and Conference divisions of the Internal Revenue Service.