On the weekend I was busy learning php and developing a photo gallery application. I couldn't find a free one that does what I wanted, so with a few examples of code I wrote an application which can be put anywhere in a file structure.
It does the following
- Show folders and image thumbnails of current subdirectory.
- Shows a breadcrumb trail of current location within photo gallery.
- Automatically creates thumbnail if necessary (first time an image is shown). If image has been updated (file date/time changed) then thumbnail is recreated.
- If a subdirectory is selected then repeat for that subdirectory.
- If an image has been selected then show that image.
- Ignores files starting with specified prefix.
- Ignores thumbnails created with this application.
- Can store thumbnails in current directory or in subdirectory.
- Show alternative title for image or subdirectory (stored as filename.title in same directory).
- Show caption for image or subdirectory (stored as filename.txt in same directory).
- Sorted either alphabetically or most recent first.
Features still to be added
- When showing image, show previous and next links (and thumbnails).
- Create list of all images in current subdirectory as current image.
- Need to expand the ignore prefix to allow for several parameters.
- Add option to list other files.
- Warn without an error if thumbnails unable to be created due to file permissions.
- Create stylesheets for the page. (I'm adding a lot of classes so many things will be possible.)
- Avoid creating thumbnail if image is below thumbnail size.
- Exclude the dot and dotdot directories.
- Deal with directories with spaces in their names.
- Need to sort month names chronologically instead of alphabetically.
Future thoughts
- Create an admin function
- Add titles and captions.
- Purge thumbnails, titles, and captions if image or folder missing.
- Upload photos.
- Add watermark to image when displaying it.
- Allow viewers to comment, storing data in a MySQL database.
Getting and formatting the right path names was the most difficult part.
- There's the real path from the server to my homepage (directory_root). This is needed for some functions, to determine if a directory can be written to, and if it is a directory or not.
- The path from the home page location to the photo gallery. As the intent is to put it in anywhere, this needs to be dynamic, and could be null.
- The path from the top of the photo gallery to the current location.
- The php script name needs to go in after the top of the gallery to correctly work, but only in the url.
- The url appears to show the directory/image being displayed. (The php grabs the url and sorts it out.)
I need to add a comment, with version, and to check out creative commons licenses. I'll make it freely available. Any suggestions about what an image gallery program should be able to do? More importantly, I need a good name for the application. Please give me some suggestions.
I am such a geek to spend my weekend doing that.
Oh, I did go to the gym on Friday and I saw The Stepford Wives too. There's a few inconsistencies but all-in-all a fun movie. If you don't expect too much you won't be disappointed. No big explosions, which I recently seem to favour in movies. Matthew Broderick has become more attractive as he's aged. Having read the reviews of the movie I'm glad I didn't see the original before it but now I want to. The inconsistencies are due to a different ending being filmed but was rejected by the test audience. Hopefully the DVD will show it. There were some nice lines in the movie, but I've been unable to find an online copy of the script.