Older Twocentsworth.com Archives

Sillyness

PHP Photo Viewer

In just a little over 200 lines of PHP, I’ve now got a strictly validating XHTML and CSS photo directory viewer.

It displays a fluid layout of thumbnails and also allows you to cycle through the full size photos. It will even display individual descriptions on the full view if you supply a txt file with the same name. It has a few customizable settings, like colors and titles, but mostly it is plug-n-play. Just make sure you name your thumbnails with a “thumb-” prefix and you should be good to go.

The code for an actual photo directory index.php file looks like this:

<?php
require_once("../include/photo-viewer.class.php");
$oImageViewer = new PhotoViewer;
$oImageViewer->PageTitle("Cumberland Gap, KY — April 2nd-6th, 2003");
$oImageViewer->SubTitle("Hensley Settlement, White Rocks, Sand Cave");
$oImageViewer->BoxWidth("100");
$oImageViewer->BorderHeight("3");
$oImageViewer->BackgroundColor("#cbd5d7");
$oImageViewer->HighLightColor("#666");
$oImageViewer->Display();
?>

So what am I doing with this code you might ask? Well first I’m going to show it to you in action with some of my very own photos.

And then I’m going to give it away under a Creative Commons License

Download Photo-Viewer Now!

Originally published on Saturday April 19, 2003 at 6:12 am

Comments were disabled for this post. This happens for a variety of reasons and most likely it's not your fault. Unless you're a spammer. Then it might be your fault.