Jump to content

Preload Images


byronrode

Recommended Posts

I have a clients website where I have designed a gallery that searches a defined folder and shows any sub folders as a category and within those folders, it shows the images.

 

I have created the thumbnail script and that works, but I want to be able to temporarily add the thumbnails into a cache of sorts.

 

If a viewer clicks on an image, they are then directed to a larger image. They can then browse the images, using a navigation system at the bottom. However if they decide to go back to the category index (thumbnails) you have to wait for each image to reload. This can be a bit irritating if there are 100 photos and you have to wait for them to load.

 

Could you direct me to some tutorials or a example script. My guess is that it has to be coded into the thumbnail creator file, but I am still trying to figure this one out.

Link to comment
Share on other sites

After much searching, and reading of articles,  I have designed another way to do it, that is not too harsh on the server and allows the images to be stored in the browsers cache, as the images are only called dynamically once.

 

Basically instead of calling the image via the thumbnail page like so:

 

<img src="thumbs.php?image=myimage.jpg" />

 

I recreated the thumbs page into a function, and then call the function, which creates the thumbnails, and saves them to a thumbs folder using

imagejpeg

.

 

I have then scripted the gallery to check firstly if there is a thumb folder, and if not create one. It then checks to see if the thumbs folder is empty or not, and if it is empty, it then creates the thumbnails.

 

I have also put a secondary check, in case my client adds more photos to the folder, that counts the number of files in the images folder and the thumbs folder, and if there are more images then thumbs, it recreates the thumbs.

 

if all the checks pass, then instead of calling the images dynamically, it shows the images within the thumbs folder.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.