PDA

View Full Version : PHP Photo Album script



davywylie
01-25-2006, 10:27 AM
hi,

I have been able to implement this script into my website, but I was sondering is it possible to replace the "photo number" with a description. Currently I have a database in my sql which contains the name of the pic i.e. sddfs.jpg, and a description

Help in this would be really appreciated

ddadmin
01-25-2006, 11:30 AM
.

I've thought about implementing a "caption" feature, though for now there isn't an easy way unless you're familiar with JavaScript. The hold up for me is how to store the captions so the script is still as easy to use as it is now- using mysql would make the script inaccessible to many people who don't have the know how to store and retreive information from a database. Right now, the script just collects all image files within a directory.

davywylie
01-25-2006, 11:40 AM
is it possible then to use the name of the file, without the jpg etc extension with javascript?

ddadmin
01-25-2006, 11:53 AM
Do you mean rename your .jpg images to serve as the caption as well, for example:

"This is a cat.jpg"?

My main concern is how some browsers handle spaces or wierd characters inside file names. Anyone know?

davywylie
01-25-2006, 12:55 PM
yeh, but even if needs be with out spaces - better than photo1 etc

ddadmin
01-26-2006, 04:48 AM
Ok, make the below changes to the frontend JavaScript to add the option of using the file names (minus extension) as the caption instead of a static text like "Photo 1", "Photo 2" etc.

Step 1:
Locate the line:


var descriptionprefix=[1, "Photo "]

inside the JavaScript, and change that to:


var descriptionprefix=[1, "filename"]

function buildcaption(i){
if (descriptionprefix[1]=="filename")
return galleryarray[i].substring(0, galleryarray[i].lastIndexOf("."))
else
return descriptionprefix[1]+(i+1)
}

Step 2:
Locate the line:


tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""

and change that to:


tempcontainer+=(descriptionprefix[0]==1)? buildcaption(i) : ""

That's it. By entering "filename" in Step 1, the script will now use the file names as caption. You can still change that to a static text, by entering "Photo ", for example.

BrightStarPro
01-28-2006, 01:45 PM
If you create your JPEGs in Adobe Photoshop like I do, you can create captions in the file when you save it. Is there anyway this script can be modified to read the caption in the JPEG file and then "write" it underneath the image when it loads?


Do you mean rename your .jpg images to serve as the caption as well, for example:

"This is a cat.jpg"?

My main concern is how some browsers handle spaces or wierd characters inside file names. Anyone know?

ddadmin
01-28-2006, 10:57 PM
If you create your JPEGs in Adobe Photoshop like I do, you can create captions in the file when you save it. Is there anyway this script can be modified to read the caption in the JPEG file and then "write" it underneath the image when it loads?

It's possible, though not using a client side language like JavaScript, but PHP for example. But going this route definitely would be overkill to implementing a caption feature. Firstly, trying to make out text from an image isn't exactly easy (based on how I understand it to work in PHP), plus, depending on the font type used in the image text, it may not reliably make it out at all. That's why you see forms asking you to enter what you see on the screen such as a 4 character image code to prevent spam- so to foul bots and distinguish between humans and a script.

BrightStarPro
01-29-2006, 06:48 PM
It's possible, though not using a client side language like JavaScript, but PHP for example. But going this route definitely would be overkill to implementing a caption feature. Firstly, trying to make out text from an image isn't exactly easy (based on how I understand it to work in PHP), plus, depending on the font type used in the image text, it may not reliably make it out at all. That's why you see forms asking you to enter what you see on the screen such as a 4 character image code to prevent spam- so to foul bots and distinguish between humans and a script.

I think you may have misunderstood what I meant by saying "captions in the file". I'm not referring to *visible* text you can see in a JPEG when you load it. I'm talking of an option in Photoshop when you click on "File Info" in the "File" pull-down menu. A menu appears where you can add "hidden" information about the JPEG such as a caption, a headline, keywords, etc... This information is saved in the *coding* of the JPEG.

Do you think it'd be possible for a script to be able to read the JPEG's coding, then extract that information, and place it beneath the JPEG in a script such as the PHP Photo Album script (http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm)?

BrightStarPro
04-18-2006, 02:03 PM
ddadmin,

I never heard back from you the idea I posted above back in the end of January. If you get a chance, let me know your thoughts if what I described is possible or not.

Twey
04-18-2006, 03:40 PM
His comment still holds. I don't know enough about the JPEG format to write a script to extract these "captions," but I suspect it could be done -- although still not with Javascript.

Nokonium
08-05-2006, 07:54 PM
I've just tried this and all my images disappear. I have it set for no thumbnails and have only gif images.