View Full Version : Thumbnail Viewer II locks up if file not found

05-20-2011, 07:45 AM
1) Script Title: Thumbnail Viewer II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm

3) Describe problem: on mouseover, if the image file is not found then the red wheel just rotates forever with the "loading large file" message. The only way to stop this is to reload the page.

05-20-2011, 02:15 PM
Unless I'm missing something, there's not much that can be done if the larger image is missing. If it were missing, reloading the page wouldn't help much. The same thing would happen again as soon as the trigger was activated. Perhaps the larger image is so large (byte size) that it's taking a long time to load. If that's the case, optimize it.

Oh, and in tests here, you can stop that loading message by activating another trigger for an image that does exist.

That said, if it is truly missing and you want to skip the loading message, use this modified version of the script:


If the image is missing, it will show the browser's missing image token in place of the missing image. Any title/caption for that image will also be displayed, and one can go on using the page and the script with no hindrance.

If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.

05-20-2011, 04:57 PM
[QUOTE=jscheuer1;253355]Unless I'm missing something, there's not much that can be done if the larger image is missing. ...

John: Thanks for the quick response. The page is still in the test phase behind a firewall. Your script is being used to display a small thumbnail of an image during mouseover of a directory listing. The image URL is actually pointing to a GD PHP function that generates a small copy of the image on the server. If the image is selected, the file name is passed to another function. Display of the full size image is not required. This all works most of the time. I will try your code and get back to you, if necessary.
// Lance

05-20-2011, 05:34 PM
Whoa, I've done some work with that sort of thing myself. I think the best thing to do would be to figure out, when it fails, why it fails, catch that and have it send some sort of generic image instead.

On the javascript side, all you can do is render something onerror, you cannot make up for the failure of PHP to produce a valid image.

BTW, in testing the official version of the script it appeared to only perhaps be an issue in IE. Is that your only target browser? Others would render the content as blank, or (if any) just the title/caption.

Important Note: I've just updated the script in my previous post with an important addition to prevent memory leaks.

05-20-2011, 09:29 PM
John: Re: IE yes problem in IE 9 using GD graphics. Re PHP: a fall back to a valid image file that says "file not found" is provided on error. Working out kinks. Thanks
// Lance

05-20-2011, 11:05 PM
Well, there might not be an error in the GD code, probably isn't since it works most of the time. I suspect it may be more of a matter of how long the browser is willing to wait around. If so, in your GD routine, you would have to supply this generic image not only on error, but also use a timer of some kind that tells it to stop trying after a certain amount of time and to send that generic image instead.

Alternatively, we could use that generic image as the content that's displayed on javascript error in the browser.