SilverBlade86 Posted January 28, 2008 Share Posted January 28, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/ Share on other sites More sharing options...
cooldude832 Posted January 28, 2008 Share Posted January 28, 2008 that will work, but be weary of storing images in a database and not flat file. If you have to dynamically recreate 100 thumbs your load times aren't going to be pretty unless you do it properly. Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/#findComment-450810 Share on other sites More sharing options...
SilverBlade86 Posted January 28, 2008 Author Share Posted January 28, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/#findComment-450814 Share on other sites More sharing options...
cooldude832 Posted January 28, 2008 Share Posted January 28, 2008 best idea is to create a thumb and then a bloated image and then when you do single image views you can take that extra time (cause its only 1 pic) to create multiple sizes of it if needed. You can store in a database so long as you do it right. Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/#findComment-450815 Share on other sites More sharing options...
SilverBlade86 Posted January 29, 2008 Author Share Posted January 29, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/#findComment-452065 Share on other sites More sharing options...
SilverBlade86 Posted January 30, 2008 Author Share Posted January 30, 2008 Bump. No one has any comments or ideas? Quote Link to comment https://forums.phpfreaks.com/topic/88109-displaying-photo-gallery/#findComment-453071 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.