Jump to content

Recommended Posts

Hi there, I am currently coding a photo gallery for my website in PHP. I would like some ideas and feedback with the code.

 

Basically, all photos are divided into years, eg 2007, 2008. In each year, there would be different events, maybe an outing to the bowling alley, or a swimming competition. Each of those events will have photos associated to it.

 

Now what would be the best way of implementing such a thing?

 

What I've got is that there would be a "photo" database, in each would contain the year, the event with it, the photo's thumbnail (which is generated when the main photo is uploaded) and the photo itself. The user would choose from a drop down box what year they want, the event they want, and the photos would be found using a SQL query and the thumbnails displayed. Then each thumbnail is linked to the actual photo.

 

Comments?

Link to comment
https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/
Share on other sites

Yes, what I meant was that when the user uploads a photo, a thumbnail is automatically generated and saved onto the server itself. That way it does not have to recreate the thumbnail each time a user wishes to view the gallery.

 

Any other better ways of doing this would be greatly appreciated. Thanks.

I had a thought about this, and I realized, this set up would only work if each photo is uploaded separately.

 

This is my new idea:

 

Ditch the database idea. My new set up goes like this:

 

I have a directory "Photos". In the "Photo" directory, I have folders for each year (eg 2007, 2008). Each "Year" directory contains multiple folders for different events, labeled appropriately (eg "Bowling", "Club Sports Day"). Each "Event" folder contains 2 directories, one for the full size image (scaled at 800x600) and one for the thumbnail (scaled at 40x30).

 

So this is what happens. The user goes to the Photo web page. The page displays all "Year" directories. The user selects a year, and is shown the "Events" directories. Then, the user is shown the thumbnails of each image. Clicking the thumbnails open up the original image.

 

What happens here is that when the images show up for the specific event, the web page would look through the original image folder. For each image in there, there will be a thumbnail with the same name as it, only in the thumbnail folder. If the full size image does not have a thumbnail associated with it, a new thumbnail is generated and stored in the folder.

 

By doing it this way, I do not have to tinker with SQL databases, storing the file paths of the images as well as the thumbnails in the database. Building up the thumbnails will be easy as well, as I could just chuck all the photos I currently have onto it and let it generate the thumbnails.

 

The only drawbacks I see about doing it this way is that the thumbnails could easily get out of hand, if uncoded properly (eg deleting the original image does not delete it's thumbnail). Also, it is possible that the load times on the server could increase dramatically due to the server having to generate thumbnails.

 

Suggestions?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.