Log in

View Full Version : PHP Photo Album script, opening a page



linoux
10-03-2013, 11:39 PM
Hello,

I'm using "PHP Photo Album script" (updated code version you posted on this forum) and it works great.
What I would like to do is to open a php page when clicking on a thumbnail picture and having the url to contain the pic filename (without the .jpg) at the end of it.


Example :

I click on thumbnail of a picture named Animals41.jpg and it open in the same window : pictures.php?n=Animals41
or
I click a picture named Guitar5.jpg and and it open in the same window : pictures.php?n=Guitar5


Hope someone can help me
Thanks you very much :-)

linoux
10-04-2013, 01:05 PM
ok i figured out myself :)

Thanks

linoux
10-06-2013, 05:48 PM
now I'm trying to do something else, for the past two days I tried but i can't get it working :
I want to put the actual filenames of the pictures under the thumbnails. I've messed up with autodesc, thumbfilename and even the .js but no luck. Not sure someone will help me

here is part of working code so far :


<script type="text/javascript">

new phpimagealbum({
albumvar: myvacation, //ID of photo album to display (based on getpics.php?id=xxx)
dimensions: [4,50],
sortby: ["file", "asc"], //["file" or "date", "asc" or "desc"]
// autodesc: "Photo %i", //Auto add a description beneath each picture? (use keyword %i for image position, %d for image date)
// showsourceorder: true, //Show source order of each picture? (helpful during set up stage)
onphotoclick:function(thumbref, thumbindex, thumbfilename){

var test=thumbfilename
test=test.replace(".jpg","")

var myurl=" channel.php?n="+test
window.open(myurl, '_self')
}
})

</script>

Thanks

jscheuer1
10-06-2013, 06:47 PM
You need to edit the script for that. Which version exactly are you using?

linoux
10-06-2013, 07:56 PM
thanks for answering me

I'm using the version you posted here :

http://www.dynamicdrive.com/forums/showthread.php?71375-PHP-Photo-Album-script-v2-11-Pictures-don-t-show-up

jscheuer1
10-06-2013, 11:55 PM
OK, that's just an update of the getalbumpics.php file to account for changes in PHP. So I'm assuming you're still using the current official version of the ddphotoalbum.js file. And I should have said the script needs to be altered, not necessarily edited.

If that's the script you're using, just put this script:


<script type="text/javascript">
phpimagealbum.routines.buildimage=function(albumvar, i, desc, showorder){
var desc=(desc && desc!="")? '<br />' + desc.replace(/(%i)|(%d)|(%s)/g, function(m){
return (m=="%i")? i+1 : (m=="%d")? albumvar.images[i][2] : ""
}) : ''
return (showorder? '<b style="color:red">Source Order: '+albumvar.images[i][0]+'</b><br />' : '') + '<img src="' + albumvar.baseurl + albumvar.images[i][1] + '" data-index="' + i +'" />' + (albumvar.images[i][3]? '<br />'+albumvar.images[i][3] : (desc)? '<br>' + albumvar.images[i][1] : '<br>' + albumvar.images[i][1]);
};
</script>



in the head of the page right after it (right after this):


<script type="text/javascript" src="ddphpalbum.js">

/***********************************************
* PHP Photo Album script v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>



It will change how each image/description pair is rendered, using the image filename as the description. It can be tweaked further if desired.

The browser cache may need to be cleared and/or the page refreshed to see changes.

linoux
10-08-2013, 12:18 AM
Hi,

it works like a charm, thanks you very much.

you say it can be tweaked further, the only thing I would tweak more is to remove the ".jpg" in the filenames under the thumbnail,
I'm trying to find how, don't know if it involve complex changes?

jscheuer1
10-08-2013, 05:26 AM
<script type="text/javascript">
phpimagealbum.routines.buildimage=function(albumvar, i, desc, showorder){
var desc=(desc && desc!="")? '<br />' + desc.replace(/(%i)|(%d)|(%s)/g, function(m){
return (m=="%i")? i+1 : (m=="%d")? albumvar.images[i][2] : ""
}) : '',
filename = albumvar.images[i][1].replace(/\.[^\.]+$/, '');
return (showorder? '<b style="color:red">Source Order: '+albumvar.images[i][0]+'</b><br />' : '') + '<img src="' + albumvar.baseurl + albumvar.images[i][1] + '" data-index="' + i +'" />' + (albumvar.images[i][3]? '<br />'+albumvar.images[i][3] : (desc)? '<br>' + filename : '<br>' + filename);
};
</script>

linoux
10-08-2013, 08:27 PM
it works great, it look simple now i see it, I have a lot to learn

thanks you so much for your help