Updated 10/27/2008 — Read more below!

There are a lot of PHP photo gallery scripts out there. I know; because I went looking for one some time ago, and found myself barraged with Javascript, AJAX, and complicated installations. I didn’t want any of those things, so in the end I just wrote one for myself — and this is the end result. Download the ZIP package.

It’s not a complicated script, and it doesn’t do a whole lot for you: but, assuming you’re running on Linux with PHP, it’ll be incredibly easy for you to install and configure. View the sample installation.

What’s in the Package?

There are six main files included in this zip package (Version 1.2):

  1. gallery.php — the photo gallery script.
  2. index.php — the home file which includes the gallery script and contains configuration info. You can copy this page to create additional galleries just by saving it with a new name and changing the configuration information.
  3. titles.txt — a simple text file which uses pipe-separated fields to indicate the image name, an image description, and an alt text option.
  4. title.php — a script which provides a unique title element for each image in the gallery.
  5. basic_styles.css — a very basic stylesheet so that your default photo gallery doesn’t look too boring. Warning: no attempt whatsoever has been made to test these styles outside of Firefox.
  6. readme.txt — installation instructions

I’ve also supplied a (very) small gallery of images for the included gallery.

What does the script do?

This is pretty straightforward. The configuration information you’ll send to the script provides the title of the gallery, the relative path to your images folder, and the name of your text file containing the image information. Using this information, the gallery script creates a page containing (in order):

  1. Navigation links to move between the previous and next images in the gallery. The sequence is the order in which you’ve listed the images in your text file. The navigation is circular, so in the initial position the previous link will send you to the last image in the gallery.
  2. A full size image with a caption. The caption is the second field in your text file.
  3. An unordered list of thumbnail images in the gallery. Again, the order is from the text file. In the default styling, the list is displayed as a panel of images rather than as a list. Each image is a link to the full sized image within the gallery.

The script does NOT automatically generate your thumbnail images. Sure, I could have done that — - but my feeling is that manually creating thumbnail images will usually be more aesthetically pleasing. My preference is to create 80×80 square thumbnails cropped from the image. The tiling effect of the unordered list is much more effective with square thumbnails; and the ability to choose a particular section of the image for the thumbnail is much nicer than whatever programmatically selected truncation might have done.

Some Small Recommendations

The script allows the ability to use an alt text on your images. It also provides a description which can be used to caption the images in a paragraph either over or under the image. To me, it’s redundant to provide both descriptive text associated with the image AND a descriptive alt attribute. Therefore, I’ve also provided the option to turn off alt text in the full sized images. The default settings are what I’d recommend: visible descriptions enabled for the full size image, alt attributes left blank, and alt attributes enabled for all thumbnails.

I also recommend keeping your alt attributes short and to the point. The reason for having separate descriptions and alt attributes is because they serve different purposes: don’t try and use the description field as an alt attribute and don’t try and use the alt field for a description!

There’s nothing fancy about this script. Really — I mean it. It’s down and dirty “make me a photo gallery” programming. Use at your own risk!

Changes as of 10/27/2008

  • Added a pagination feature, allowing you to set the number of thumbnail which will display at one time.
  • Added a few minor display options, to more easily move or remove elements such as skiplinks, change the text for previous/next labels, etc.

The changes are relatively uninvasive, but you will need to add the new options into your existing gallery index pages. Other files can simply be overwritten; but be careful not to overwrite your titles.txt files!

Changes from 7/7/2007

I’ve made a number of small changes, including correcting some missing closing tags (oops!). The biggest change is that the Easy PHP Gallery is now capable of being a bit more search friendly. I’ve done a little rewriting to make the script capable of providing unique title elements for each image, rather than just giving the main gallery page title for every single page. This does make the script a tiny bit more difficult to implement, I suppose — but I’d say it’s worth it.