PDA

View Full Version : PHP Photo Album 2.11 - Image Title from File Name



cpthompson82
04-14-2010, 09:19 AM
1) Script Title: PHP Photo Album 2.11

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

3) Describe problem: I have installed an un-modified version of this script on a website I am creating for someone ... http://www.rjt-online.com/2010%20Website/photos3.php

The only mods I have made to the script is altering the images sizes.

How can I get the script to use the image file name (minus the file extension) as the title to be placed underneath each image?

I have found a few threads regarding this but they all seem to be relating to an older version of the script and arent relative to v2.11.

If an images was names ie "The House.jpg", I would like a title to appear underneath the image saying "The House".

As it stands, I can't get the date %d or default %i to display below the existing images. At present I have it set to "".

Does anyone know how I can modify the script to do this?

I would like to try and keep to the basic script and not introduce the new version of lightbox or anything.

Any help would be appreciated.

Thanks!

lmellor
12-13-2010, 04:09 PM
I have found a few threads regarding this but they all seem to be relating to an older version of the script and arent relative to v2.11.

I am also in the same predicament, I would expect this to be a standard function for this script since it is mostly dynamic, setting custom titles seems a little manual compared to just using the filenames.

the closest I have found so far was to add...


<script type="text/javascript">

(function(id){
for(var i = 0; i < id.images.length; ++i){
id.desc[i] = id.images[i][1].replace(/\.[^\.]+$/, '');
}
})(myimages);

</script>

to the head section, this doesn't appear to have broken anything, though I don't know how to go about employing this in my script call on the page body.

Could anyone help at all?

jscheuer1
12-13-2010, 05:40 PM
Use this instead of Step 1 from the demo page:


<script type="text/javascript" src="http://www.mysite.com/myimages/getalbumpics.php?id=myvacation"></script>

<script type="text/javascript">
(function(av){
var re = /\.[^\.]*/, avi = av.images, i = avi.length - 2;
for (i; i > -1; --i){
av.desc[i] = avi[i][1].replace(re, '');
}
})(myvacation);
</script>

<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>

<link rel="stylesheet" type="text/css" href="ddphpalbum.css" />

If you use the same (highlighted and red) variable for both the getalbumpics.php?id and in the function, the script will take care of the rest. Just install the rest of the script as you normally would.

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.