View Full Version : Lost image description in PHP Photo Album script

07-30-2010, 04:22 PM
1) Script Title: Swiss Army Image slide show script - John Davenport Scheuer: combined with PHP Photo Album script

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

3) Describe problem:

A couple of years ago John Scheuer was kind enough to help me customize these scripts to suit my needs. I have used the code on several websites to display a slideshow and use the description from the slideshow as the pop-up window image description when you click on the thumbnail. The problem is that on the older websites the code works perfectly whereas on the newer websites the code no longer displays the description when you click on the thumbnail. I have tried & failed many times to figure out what is wrong. I swear I am using exactly the same code. I can't find the problem. I'm hoping perhaps John can see what it is I have done to adulterate his lovely code.

This is the code from the html page where the slideshow & thumbnails are:

var dimension="6x"+Math.ceil(galleryarray.length/6); //number of images across and down, such as 4x2, 3x1 etc
var imagepath="../img/<?php echo $artist;?>/th/" //Absolute path to thumbnail image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable
var popupsetting=[1, "width=669px, height=694px, scrollbars, resizable"]
var descriptionprefix=[0, ""]
var gsortorder=""
var targetlinkdir="../img/<?php echo $artist;?>/<?php echo $folder;?>/"; //large images
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])
<script src="../js/dd-thumbnails.js" type="text/javascript"></script>

I think this is the relevant code from dd-thumbnails.js...

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var desc='';
for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(targetlinkdir,'') ; i > -1 ; --i)
var popwin=open('', "popwin", popupsetting[1]);
'<\/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);

Here is a site where it is working properly... http://www.sargentsfineart.com/artist/johnson.php

Here is a site where it is not working properly (no description on popup)... http://www.costgallery.com/artist/curtis-all.php

I swear I have been trying to fix this for over a year, so here I am with my tail between my legs admitting defeat. Would really appreciate some fresh eyes on what I cannot see. Thanks.

07-31-2010, 04:45 AM
Hi kuau,

I didn't know you had a tail . . . perhaps things could have been different.

Just kidding.

Anyways, you are right in a general way as to where in the code the problem is arising. Specifically it's here (from your second posted code block):

for (var i = galleryarray.length-1, lookup = imgsrc.href.replace(targetlinkdir,'') ; i > -1 ; --i)

The reason being that, in the page that works, you earlier specify the targetlinkdir in absolute terms, and in the one that doesn't work you use relative terms -


var targetlinkdir="http://www.sargentsfineart.com/img/johnson/lg/"; //large gallery

doesn't work:

var targetlinkdir="../img/curtis/all/"; //large images

Using the absolute path could fix it, except that there is no guarantee that in either case (where it works and where it doesn't) that the www part will always be there.

So I would suggest (first where it's not working, and if this fixes it there, also where it is working) changing:

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)

That way, regardless of whether you use the relative or absolute path for targetlinkdir, and regardless of whether or not the page is navigated to using the www part, the lookup value should work out to be correct.

Just make sure, after making the change, that you clear the browser's cache before viewing the page. Otherwise you may still be getting the results of the old code.

07-31-2010, 05:33 AM
Dear John: I knew you would see it right away. For over a year I was too embarrassed to admit I screwed up your code. Now I feel like even more of an idiot because I should have noticed the absolute/relative variance. That did fix it, but I also made the other change you suggested. I am thrilled to have this working again and really appreciate your help. I just wish I didn't have to bother you for something I should have been able to fix myself. But I love that you further improved the code. Thank you so much!

You are the greatest. e :)