PDA

View Full Version : Image description doesn't always show



kuau
12-18-2011, 06:16 PM
1) Script Title: PHP Photo Album script

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

3) Describe problem: I am using an old version of this script with some customizations added by John Scheuer. I don't want to upgrade because I don't like LightBox and the old script does exactly what I want (thanks to John). At one point the descriptions stopped showing and it turned out to be because I had used a relative path to targetlinkdir so John changed one line of code so the path wouldn't matter. I started noticing that this new version caused (I'm assuming) the image description not to show up the first time you clicked on a thumbnail, but it would show up the second time. I'm hoping this is easily fixable but it makes no sense to me. On some of my old sites it works just fine, but when I use the old code on the new site, the same problem manifests. I swear I didn't change anything but the one line, and then I changed it back and used an absolute path.. same problem. How did I break it?!

Here is the script that seems to be causing the problem...


function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var desc='';
for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(targetlinkdir,'') ; i > -1 ; --i)
//for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(/^.*\//,'') ; i > -1 ; --i) [ this is the new code ]
if(galleryarray[i][0]==lookup)
desc=galleryarray[i][1];
var popwin=open('', "popwin", popupsetting[1]);
popwin.document.write('<title>'+desc+
'<\/title><body style="margin:0;padding:0;font:85% sans-serif;text-align:'+
'center;overflow:auto;background-color:#0b151e;color:#cccccc;"><img title="'+
desc+'" alt="Larger Image" style="margin:2px 0;" src="'+imgsrc.href+'"><br>'+desc);
popwin.document.close();
popwin.focus();
return false;
}
else
return true;
}

and this is the script on the page that shows the thumbnails...


var popupsetting=[1, "width=694px, height=700px, scrollbars, resizable"]
var descriptionprefix=[0, ""]
var gsortorder=""
var targetlinkdir="http://www.website.com/img/"; //large images
(function(){
for (var i = galleryarray.length-1, j ; i > -1 ; --i)
for (j = slides.length-1 ; j > -1 ; --j)
if(slides[j][0].replace(/^.*\//,'') == galleryarray[i][0])
galleryarray[i][1]=slides[j][1];
})();

It's driving me crazy. Thanks, e :)

jscheuer1
12-18-2011, 08:00 PM
If reverting to the old code and using the absolute path doesn't fix it, it has nothing to do with the new code. It sounds as if galleryarray[i][1] is empty at that point, but how would it get filled later? Or maybe the style isn't working, so it's there but invisible for some reason. But again, how would it appear later?

According to the code, the description is supposed to show up as the title of the popup window, the title attribute of the image in the popup and as descriptive text on the page in the popup underneath the image in the popup.

Are all three of these not showing up the first time?

Anyways, I'd have to see it. Please supply a link to a demo of the problem and tell me which browser(s) your seeing the problem in.

kuau
12-18-2011, 08:16 PM
Thanks for taking a look at this. The description does show in the title of the popup window and also as the alt tag the first time, but not under the picture. I know, it doesn't make sense. You can see it flash at the top of the window but I guess the picture covers it. I am using IE 9 with Win7 Home Premium 64 bit. You can see the problem here...

http://www.terryritterart.com/art/mardi-gras.php

jscheuer1
12-18-2011, 09:35 PM
It actually is there the first time. Only problem is it's black - barely noticeable against that dark blue background. IE 9 doesn't see the body as extending that far for some reason. If you click on the description it will show up. But that's no help. This is - change the function that makes the popup as shown:


function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var desc='';
for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(targetlinkdir,'') ; i > -1 ; --i)
//for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(/^.*\//,'') ; i > -1 ; --i)
if(galleryarray[i][0]==lookup)
desc=galleryarray[i][1];
var popwin=open('', "popwin", popupsetting[1]);
popwin.document.write('<title>'+desc+
'<\/title><body style="margin:0;padding:0;font:85% sans-serif;text-align:'+
'center;overflow:auto;background-color:#0b151e;color:#cccccc;"><img title="'+
desc+'" alt="Terry Ritter Fine Art" style="margin:2px 0;" src="'+imgsrc.href+'"><div style="color:#ccc;">'+desc+'</div>');
popwin.document.close();
popwin.focus();
return false;
}
else
return true;
}

Notice the color (highlighted in red), it should be the same color as the color in the body tag (#ccc is shorthand for #cccccc).

kuau
12-18-2011, 11:26 PM
Thanks, John. When I first added the <div> part, it seemed to work fine, but when I went to a diffferent page and clicked on a thumb, instead of a popup window, the thumb opened a full screen white window with the image in the top left corner. So then I shift-reloaded and tried another thumb.. same white screen. So I tried it on a totally different site and the same thing happened. So I closed the browser and everything seems to be OK now. When I made the change to the js file did it act weird because of what was in the cache? Makes me nervous when things don't behave logically.

Thanks very much for your help.

jscheuer1
12-19-2011, 04:48 AM
"Makes me nervous when things don't behave logically."

You must be nervous a lot. :)

I've never heard of exactly that happening. But I did discover while working on this from a local mock up that once I had tried all the thumbs I had to clear the browser cache from an empty page, close the browser completely and then reopen it and go to the test page again to see if it was working or not.

So the cache was definitely involved, and more deeply than is usual because usually I can just go to a blank page clear the cache and reload the test page.

As long as it's working now, I'm sure it's fine.

kuau
12-19-2011, 05:51 AM
Ha! That cracked me up. Fortunately, computers are pretty logical most of the time... it's people I have to avoid. :)

It's very reassuring to know that you experienced the same odd occurrence. I'll take your word for it being fine, move on to my next dilemma, and go rescue another cat. :) Thanks a million for always being there for everyone. Merry Christmas!