Making a PHP Photo Album?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
MikeJoel
Forum Newbie
Posts: 8
Joined: Wed Feb 22, 2006 8:50 pm

Making a PHP Photo Album?

Post by MikeJoel »

I want to make an album that may have like 100 photos but only 5 are ever on the screen at once.

Something like a view box in the middle. Below that 5 thumbnails. Then a rewind and forward button on either side of the thumbnails to let the user move one photo forward or backward in the group. By clicking on a thumbnail it shows the photo in the box above (view).

My problem is I have been playing around with it and have found it isn't working.
PHP only works on page encoding so nothing is "live". I don't want to reload the page every time a user moves forward or back.

I can't use javascript since it cant read files and I was using files that contained the name of the thumbnail (full path), the path to the full photo and a caption text for each photo.

Any ideas?
I was wanting to make it small enough to fit on my front page.

Mike
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Sure you can use Javascript. Just use PHP to get the file list and then dynamically print the JS you need to the browser.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you could also use ajax -- this will avoid having to load all pictures at once, instead only have to fetch the next photo at a time
MikeJoel
Forum Newbie
Posts: 8
Joined: Wed Feb 22, 2006 8:50 pm

Post by MikeJoel »

So something like a loop in php that assigns all the photos in the album to javascript array?

Would this cause the page to download them? Because if you have like 100 photos at 57Kb each that would be 5.7Mb which would take a long time for a dailup user.

Mike
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I've also wondered about this before.

Pagination would be quite easy if you grabbed all the files, put them in a MySQL DB and then pulled them out as needed, but how can you paginate through files if you are just pulling them from a directory?

The only way I can think of is to loop through all the files every time and count as you go past each file and then eg. if you were on page one just do while counter <= 5, on page 2 do while counter > 5 and <= 10, surely that isn't the only way to do it though?
MikeJoel
Forum Newbie
Posts: 8
Joined: Wed Feb 22, 2006 8:50 pm

Post by MikeJoel »

The problem with that is that thr page has to be reloaded with every grab of a group of 5 photos. I am trying to prevent a reload. I have settled on allowing it for every album.


I did a test and found as long as the variable is not created and a "new Image()" it will not cache. Just using a normal variable to hold the string (which is the path to the photos) just acts like a string and only when placed as the image's src triggers the downloading.


Mike
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Oh, if you want to prevent the page from reloading you could use JavaScript/AJAX, or just include your little photoalbum bit in an iframe so that only that refreshes.
Post Reply