![]() |
|
Mozilla link prefetching using <link> tag - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Mozilla link prefetching using <link> tag (/thread-1823.html) |
Mozilla link prefetching using <link> tag - teedog - 2007-11-19 I would very much like the browser to prefetch or preload the next image in the particular album to optimize browsing performance. I realize that Test-JS has a JavaScript function for that purpose, but that theme is for testing purposes only at the moment. Would the `` tag be a simple way of making Mozilla-based browsers prefetch the next image? Read about link prefetching here. I inserted this code in the header section of image.php: ` Mozilla link prefetching using <link> tag - teedog - 2007-11-19 I was able to get the link of the next default sized image using the following code: `if (hasNextImage()) {
}` However, how do I return the context to the image I was on before I moved forward with I tried Mozilla link prefetching using <link> tag - sbillard - 2007-11-19 You will have to save $_zp_current_image somewhere then restore it. However, the approach you are taking will have problems with image pagination. I think a better approach is to use something like: `$imagarray = $_zp_current_album->getImages(0); $nextimage = $imagearray[imageNumber()+1];` You do, of course, need to be sure there is a next image. Mozilla link prefetching using <link> tag - teedog - 2007-11-19 I was able to get the name of the next image using ` $imagearray = $_zp_current_album->getImages(0); $nextimage = $imagearray[imageNumber()];` $nextimage is now a text string, the file name of the next image. But how do I get the URL to the default sized image of that name? getDefaultSizedImage() doesn't take parameters and only returns the default sized image URL of $_zp_current_image. Thanks for your help. Mozilla link prefetching using <link> tag - sbillard - 2007-11-19 YOu can make a new image object from the name:
Then use or Mozilla link prefetching using <link> tag - teedog - 2007-11-19 Thank you thank you! The following code in image.php's head section seems to be working for me. This should make all Mozilla-based browsers prefetch the next page and image while you are viewing any image in an album, provided there is a next page/image and you are displaying the default sized image. ` ` Please let me know if there's anything wrong with it. Mozilla link prefetching using <link> tag - aitf311 - 2007-11-19 Works like a charm for me! You just forgot the slash before the n on the links. Any chance of making this into a function? And do you know if mozilla-based browsers load this last? Mozilla link prefetching using <link> tag - sbillard - 2007-11-19 This might be better from an efficiency standpoint: $n = imageNumber(); if ($n < count($my_image_array) {
}` Not sure why you have the two echo statements. Isn't the second enough? Mozilla link prefetching using <link> tag - teedog - 2007-11-19 aitf311: Glad I'm not the only one interested in this, though I probably lack the experience to make this into a neat function. sbillard: Ah, so If you mean why I have 2 prefetch hints, one for If you mean why I don't combine everything into 1 echo statement, no reason. Just clearer to write. zenphoto devs rock. P.S. Hmm bbpress forums are stripping the slash in \n. Mozilla link prefetching using <link> tag - tummblr - 2007-11-29 I made this feature into a plugin and modified the code a bit. From my rudimentary profiling, the above code took about 0.1 seconds to execute. This version takes about 0.01 seconds. http://www.tummblr.com/my-code/zenphoto-plugin-link-prefetching-hints/ |