Image Gallery by Tom Parker <firstname.lastname@example.org>
Released under the GPL Version 2 (http://www.gnu.org/copyleft/gpl.html)
Latest version of this script can be found at http://tevp.net/projects/gallery/
- 1.0 - First released version
- 1.1 - Minor fixes, added www_user/www_group
- 2.0 - Added comments capability
Florian Ferrand - bug fixes, improved documentation
- gallery.php - Browsing template script
- pictures.php - Browsing support script (don't edit!)
- show.php - Display template script
- display.php - Display support script (don't edit!)
- set_desc.py - Python script for adding descriptions.txt to a tree of image folders
- html.py/docs.py - Rebuilding scripts for the documentation, written using RST (developers only)
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.
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!
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.
- Location of the folder with the pictures in (mandatory)
- 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.
- Path and filename to the display script - can be relative to the browsing template (mandatory)
- How many pictures to show across the page (default value : 4).
- Maximum number of pictures/page. Looks better if it's a multiple of $width, but this isn't essential (Default value : 24).
- Keep aspect ratio when generating thumbnails. 1 = Keep aspect ratio ; 0 = stretch pictures (default value = 1).
- User who will own the thumbnail directories (doesn't work in PHP safe mode). If not set, uses PHP defaults.
- Group who will own the thumbnail directories (doesn't work in PHP safe mode). If not set, uses PHP defaults.
- Separating string between each directory in the list on browsing pages.
- Path and filename to the gallery script - can be relative to the display template (mandatory)
- Show/allow user-contributed commenting - 1 = allow, 0 = deny. (default = 1)
Sensible complaints with detailed error reports to email@example.com 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...
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.
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:
- The Description can contain HTML code.
- You don't have to describe all images.
- For a description of the whole folder, use the filename "."
Example descriptions.txt file:
.:Holiday in Paris DSCN1234.JPG:Meet the Dalai-Lama DSCN7777.JPG:An evening at the Moulin-Rouge
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.)