Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 02-19-2007, 03:54 PM
joe_ob Offline
forum loafer
 
Join Date: Aug 2005
Posts: 6
preloading images

Hello there, does anyone know of a simple way to preload images? This should mean that the second image begins loading as soon as the first is done?

I'm useless at code and have spent a while trying to figure this out, but I do feel as though it will help the usability of pixelpost.

Any ideas welcome.

Cheers,

Joe
Reply With Quote
  #2  
Old 02-20-2007, 01:49 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
This is not a bad idea.

I'll throw a quick addon together to grab the image name of the previous image.
Reply With Quote
  #3  
Old 02-20-2007, 02:39 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Here it is: Simple Image Pre-loader v0.1

You can use this with whatever javascript pre-loading script you wish.

Use the new template tag, <PRELOAD_IMAGE_NAME> to grab the previous image name for pre-loading.

Here is a extremely simple javascript pre-loader example:

HTML Code:
<script type="text/javascript">
if (document.images) 
{
   img1 = new Image();
   img1.src = "images/<PRELOAD_IMAGE_NAME>";
}
</script>
Note, if the last image has been viewed, the addon will go back and use the first image name.
This may be useful if you have the wraparound image addon installed.

If you know what you're doing, feel free to modify the addon to your liking.
Reply With Quote
  #4  
Old 02-20-2007, 02:41 PM
jaywilliams's Avatar
jaywilliams+ Offline
Team Pixelpost
 
Join Date: Sep 2005
Posts: 1,003
Send a message via AIM to jaywilliams Send a message via MSN to jaywilliams Send a message via Yahoo to jaywilliams Send a message via Skype™ to jaywilliams
It may be a good idea to add this to the bottom of the template, rather than the top.

That way the browser will load the current images first before trying to preload.

Also, by adding something like this to the header of your site will cause FireFox to preload when it is idle:

HTML Code:
<link href="images/<PRELOAD_IMAGE_NAME>" rel="prefetch" />
__________________
Jay Williams | A Different View

Last edited by jaywilliams; 02-20-2007 at 03:34 PM.
Reply With Quote
  #5  
Old 02-20-2007, 03:09 PM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Good idea Jay.

You can use the addon to do all of that. All the addon does is fetch the previous image name. Use the tag in anything you want
Reply With Quote
  #6  
Old 02-20-2007, 10:12 PM
joe_ob Offline
forum loafer
 
Join Date: Aug 2005
Posts: 6
Sounds good, but I'm not clear. First do I install the add on, and then do I add the text from Jay (if so, what page do I add it to?)?

Thanks for the help so far, I hope others find it helpful too.
Reply With Quote
  #7  
Old 02-21-2007, 08:49 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Yes, the addon is necessary to retrieve the image name to be preloaded.

So install the addon and use whatever pre-load script you wish.

My example pre-loads the next ("previous") image as the page loads so essentially, you are loading 2 photos instead of 1. This will slow down your page loading times for visitors with slow connections. It should not bother high-speed users though.

What Jay is showing you is an alternative method that can be used to load your images in the background after the page has loaded.

This is nice but the code he posted above only works with some mozzila based browsers as far as i know.
Reply With Quote
  #8  
Old 04-07-2007, 05:31 AM
Ariel Offline
pp regular
 
Join Date: Dec 2005
Posts: 32
Works like a charm in both FF2 and IE7. Thank you!
__________________
Photoblog

Last edited by Ariel; 04-08-2007 at 08:04 AM.
Reply With Quote
  #9  
Old 08-20-2007, 03:54 PM
irishblue Offline
forum loafer
 
Join Date: Dec 2006
Posts: 18
Red face

Quote:
Originally Posted by dwilkinsjr View Post
Here it is: Simple Image Pre-loader v0.1

You can use this with whatever javascript pre-loading script you wish.

Use the new template tag, <PRELOAD_IMAGE_NAME> to grab the previous image name for pre-loading.

Here is a extremely simple javascript pre-loader example:

HTML Code:
<script type="text/javascript">
if (document.images) 
{
   img1 = new Image();
   img1.src = "images/<PRELOAD_IMAGE_NAME>";
}
</script>
Note, if the last image has been viewed, the addon will go back and use the first image name.
This may be useful if you have the wraparound image addon installed.

If you know what you're doing, feel free to modify the addon to your liking.
Is there a way to make the preload work with the Secret add-on at:
http://www.pixelpost.org/forum/showt...ghlight=secret ?
My secret images seem to load really slowly even after the mouse has moved over the trigger image.

If my images have a standard file naming such as image1-before.jpg and image1-after.jpg, is it possible to make it work? Sorry not really familiar to scripting to modify it myself.
Reply With Quote
  #10  
Old 08-21-2007, 04:26 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
I am not familiar with the secret image addon but yes, it can be done.

When I'm not too busy i'll see what I can do.
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 09:46 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs