Skip to main content.

Image Gallery by Tom Parker <palfrey@tevp.net>

Released under the GPL Version 2 (http://www.gnu.org/copyleft/gpl.html)

Versions:

Latest version of this script can be found at http://tevp.net/projects/gallery/

Contributions

Florian Ferrand - bug fixes, improved documentation

Files included:

Requirements:

This PHP script requires PHP, and the GD graphics management extension to PHP.

Purpose and features:

The image gallery script generates thumbnail pages corresponding to picture folders. It allows browsing of separate picture folders and displays all images within the selected folder as clickable thumbnails, which link to the full-size pictures with comments. Users can also add comments to the pictures (this can be toggled on/off at install time). This script does not provide an upload function, but it will automatically build or rebuild galleries for folders and files uploaded to the web server.

Installation:

Download the latest zip, unzip it and setup the template scripts with your settings, and then point your browser at the location of wherever you have placed the browsing template script (named 'gallery.php' by default, but you may wish to rename it to 'index.php') in your web server. All should now work!

Configuration:

Each of the templates has a <script language="php">...</script> section, which consists of a series of parameters (of the form $variable_name = value;) and an "include" line. The main scripts don't have to be placed in the same folder as the templates, but if they're not, you'll need to alter the include line to point to the location of the scripts. The parameters for each template are as follows - some are mandatory, others have default options that you might want to override.

Parameters common to Browsing and Display

$pictures
Location of the folder with the pictures in (mandatory)
$header
Header to display above the gallery. Must be a php script. $my_dir (current subdirectory of the pictures directory) has been defined before the Browsing script runs this script, and $base_image (filename being displayed) has been defined before the Display script runs this script.

Browsing parameters

$display
Path and filename to the display script - can be relative to the browsing template (mandatory)
$width
How many pictures to show across the page (default value : 4).
$max
Maximum number of pictures/page. Looks better if it's a multiple of $width, but this isn't essential (Default value : 24).
$keepaspect
Keep aspect ratio when generating thumbnails. 1 = Keep aspect ratio ; 0 = stretch pictures (default value = 1).
$www_user
User who will own the thumbnail directories (doesn't work in PHP safe mode). If not set, uses PHP defaults.
$www_group
Group who will own the thumbnail directories (doesn't work in PHP safe mode). If not set, uses PHP defaults.
$dirsep
Separating string between each directory in the list on browsing pages.

Display parameters

$show
Path and filename to the gallery script - can be relative to the display template (mandatory)
$comments
Show/allow user-contributed commenting - 1 = allow, 0 = deny. (default = 1)

Bug reports:

Sensible complaints with detailed error reports to palfrey@tevp.net may be answered. As always bribery (alcohol, hardware, sexual favours, etc) may help your case, but YMMV. Caveat emptor! Remember that I do occasionally have better things to do with my time...

Potential problems:

PHP servers with safe_mode set to 1 may cause problems with the creation of the 'tn' directories, specifically because the webserver may not have permissions to write to your directories, and it almost certainly can't do the necessary chown'ing. If you see errors like

Warning: mkdir(tn): Permission denied

then you've got this problem. To solve this, you need to create a 'tn' directory in each new image folder. The webserver must have write permissions to this folder (chgrp'ing to the 'www' group and giving group write permissions works for me). PHP in safe mode can't do this, as it's running as the webserver user, which doesn't have write permissions to your folders.

Optional : adding image descriptions

Descriptions can be added to the full-size images using the "descriptions.txt" file. You need to create a text file called 'descriptions.txt' inside the same folder as the images you want to describe. This file should contain one line for each picture you want to describe, with the following syntax:

filename:Description

Example descriptions.txt file:

.:Holiday in Paris
DSCN1234.JPG:Meet the Dalai-Lama
DSCN7777.JPG:An evening at the Moulin-Rouge

Creating the descriptions.txt files fast:

You can generate the description files automatically by running set_desc.py with an argument of the root folder that you're storing images in. This will add descriptions.txt files (merged with existing ones, blank comments for all un-commented images) to that folder and all of its subfolders that contain at least one image. (Note: this script is not I repeat not robust, and will probably break if you don't have read/write/execute permissions to the folders, or give a folder that doesn't exist. In the event that you find a problem, know python, and can be bothered fixing it, patches are welcomed.)

  Page by Tom Parker <palf...@tevp.net>
This page was last updated on 13/11/2007 at 08:54:40 and has had a finite number of hits.
Listening to: Buzzcocks - Lipstick
Is that a chapstick in your pocket or am I going to have to terminate you?
FOAF Get FirefoxValid XHTML 1.0!