Start ::
PostNuke 0.7 Support ::
Tutorials and Solutions ::
Dynamic Image Preloader - Xanthia Plugin
Moderated by: Support Team
-
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
while working with a fairly image intensive theme, i noticed that a few images would lag on load, popping in haphazzardly .. so i started thinking about a preloader, but I didn't want to have to list every stinking image in the image array for every template ("laziness begot innovation"
) .. note that this is a hack and may not be suitable for all applications.
edit: anticracker won't allow the code to be posted.
read it here
..if you've got any improvements..post 'em here
enjoy!
-IR
..now back to work
-----
http://www.invalidresponse.com -
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
.sorry.. I just realized when revisiting this thread that the directory wasn't defined and there were a few other fixes since.. i've updated the tutorial..
since it loops through the images the last image was being defined as "" .. which probably isn't the best way to go about it..but I'm not much of a javascript guy, so whattaiknow.. anyway.. close that loop by adding a 1x1 pixel gif to your document root or define the path of it in the var imagename array() ..
-----
http://www.invalidresponse.com -
- rank:
-
Professional
- registered:
- February 2004
- Status:
- offline
- last visit:
- 14.08.08
- Posts:
- 1015
-
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
I wasn't even sure it would work.. but it definitely cured my woes
..as for your suggestion, this particular theme i'm working with uses a background image on all templates, so I did move that image to it's own folder and drew the path to it as the end of the loop.. so it's preloading an image that's actually used instead of the 1x1.
setting the directory of where the images are preloaded from is cool in concept, but I'm not exactly sure how efficient.. once the "lot" is preloaded, they're already cached by the browser.. so I was thinking about setting a session variable like:
pnSessionSetVar('preloaded',1);
then on the next page that's viewed we can check if the variable exists:
if(pnSessionGetVar('preloaded') == 1){
return; // already been done
}
this would stop the process and prevent preloading what's already been done.. I haven't tried it yet, but I'll let you know when I do
-----
http://www.invalidresponse.com -
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
-
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
sure would
..post back when you've got it all set up
kidding.
..i've got way too much to do, otherwise i'd oblige.
-----
http://www.invalidresponse.com -
- rank:
-
Professional
- registered:
- September 2003
- Status:
- offline
- last visit:
- 21.10.07
- Posts:
- 2423
I wish I had more..
..damned bills keep coming though. apparently I've buried myself in obligations again.. mostly done with the biggest of the 3, half done with the second and haven't started the third :? ..as long as a couple bucks come my way the 'ol lady doesn't harp as much
..i've got an eye on a 17" powerbook, but I just bought a mini so it's kinda on the back burner for a little while.. the laptop would add plenty of extra screen time.. and reduce the harp factor
-----
http://www.invalidresponse.com
Start ::
PostNuke 0.7 Support ::
Tutorials and Solutions ::
Dynamic Image Preloader - Xanthia Plugin

