I often see fellow web developers with their own domain names using web services such as Flickr to host a very simple gallery with only a handful of pictures. I prefer to host my own content since it keeps users on my side and allows me to customize the gallery layout as well as display my own advertisements. If you think it is complicated or tiresome to create a simple gallery from a directory of images, then think again - the code below fits in only 64 lines and will create the thumbnails directory automatically and list the files within it. You should specify the password on the first line of the make thumbnails script since it is a memory intensive script which could bring down a server if repeatedly called - to activate it pass the secret password in the URL (make_thumbs.php?pass=mypassword).
Source Code - make_thumbs.php
Source Code - view_thumbs.php
Once the thumbnails have been created you can view them using the view_thumbs.php file. It has extra filtering enabled to hide any pictures that do not have a full sized version (such as deleted pictures), therefore if you need to delete an image you could only delete the full sized original.
Source Code - index.php
Linking to the view_thumbs.php file is often cumbersome, and if indexes are enabled on the server simply asking for the directory path could return the contents of the directory. I would suggest creating an index file within the main folder which simply includes the view_thumbs.php file.
If you happen to use this script on one of your galleries then please feel free to send me an email and get a link to your site on this page.
________________________________________
/ 'Cow says: Thank you for visiting. You \
| are browsing: Making a Quick PHP |
| Gallery with Thumbnail Generation. You |
| have been to 1 pages on this site |
\ today.' /
----------------------------------------
\ ,__,
\ (oo)____
(__) )\
||--|| *