Shower

Before I sold my soul to the flickr squad, I wrote a little php script to automagically generate galleries from pictures in a folder. I’m posting it up because it still has some use, and it’s a crime to sit on useful code. It’s particularly useful when pared with an .hataccess file that puts a password on a directory: instant gated gallery, good for sharing photos you want limited access to.

Here’s how it works. You upload a folder full of pictures. You point shower.php to it. That’s it. Caching works too!

It defaults at 4 rows by 4 rows of thumbnails, size 100 by 100, but that can be all changed very easily. It generates thumbnails on the fly and caches them(see below) thanks to James Heinrich.And here’s the code:

shower.zip

Enjoy, and all I ask is that you show me where your site is when you use this, and that you link back to this site when using it.

Update:

If you want to enable thumbnail caching (and I suggest you do) follow the instructions in phpthumb/phpThumb.config.php. Or follow these.

In your top level directory, create a “cache” directory and give it 777 permissions.

mkdir cache chmod -R 777 cache

In the phpthumb/phpThumb.config.php change this:

$PHPTHUMB_CONFIG['cache_directory'] = ”; //$PHPTHUMB_CONFIG['cache_directory'] = ‘./cache/’; //$PHPTHUMB_CONFIG['cache_directory'] = $_SERVER['DOCUMENT_ROOT'].’/cache/’;

to this:

//$PHPTHUMB_CONFIG['cache_directory'] = ”; //$PHPTHUMB_CONFIG['cache_directory'] = ‘./cache/’; $PHPTHUMB_CONFIG['cache_directory'] = $_SERVER['DOCUMENT_ROOT'].’/cache/’;

And now the first time your particular page is loaded, the created thumbnails will be cached. This will take a serious load of your server. The author of phpThumb recommends using a cache directory relative to the individual image, but that would take away from the simplicity I’m going for with the “all you need is your pictures in a folder” approach.