PHP Image Gallery
Example
Description
- This is an image gallery script that allows you to simply upload new full sized images in FTP and the script will automatically create the thumbnails for those images and add those images to a paged thumbnail gallery suitable for browsing.
Download
Terms of Use
- Version 1.2.0 and onward is released under GNU General Public License. Basically this means you are free to use the script, modify it, and even redistribute versions of your own under the same license.
What's new
- 1.2.1 [January 13, 2008] - Code went through another cleanup and comment updates. Goal is to make it so anyone can easily modify it themselves.
- 1.2.0 [December 26, 2007]
- Stripped out broken Imagemagick support.
- Cleaned up the code.
- Better commented everything.
- Redid the gallery layout to use CSS the user can easily change.
- Changed the License to GNU General Public License.
- 1.1.0 [June 2, 2006] - Started cleaning up the code. This version was never publicly released
- 1.01 [May 11, 2004] - Initial release
Instructions
gallery.php settings
- Open gallery.php and scroll down to about line 30 and look for $config['size']. Set this to the maximum width or height you want your image thumbnail to be.
- On the next line in the $config['imagequality'] set this to the JPEG quality you would like your thumbnails to be. I recommend you keep it set to 70
- $config['rows'] and $config['cols'] are the number of rows and number of columns of thumbnail images you want shown on each page
- $config['maxShow'] is the number of page numbers to show at one time. for instance if you have 100 pages of images, you can set this to only show the page numbers of the 10 pages close to where you currently are
- $config['fulls'] is the relative path to the full size images located on your server. Include the trailing slash. example: $config['fulls'] = "photos/";
- $config['thumbs'] is the relative path to where you want the thumbnail images to be stored. Include the trailing slash.
File Permissions
- You'll need to change the permission on the directory you set $config['thumbs'] to. CHMOD it to 775 or 777 so PHP and GD2 can automatically write and create your thumbnails in that directory.
Changing the Look
- The entire gallery table is controlled by the CSS settings you'll find toward the bottom of the gallery.php file. I tried to comment each specific part of the CSS and what it controls so you can easily change the look of the gallery without actually having to actually edit any of the PHP.
Lightbox
Lightbox Support (OPTIONAL)
- I've had multiple people want to know how to make this gallery work with the Lighbox script or telling me that they modified it (which is great!) themselves. While the above gallery script does not come with Lightbox support, modifing it to work with Lightbox requires very minor changes.
- In gallery.php edit line 116 to add rel="lightbox" so it becomes echo '<a href="'. $config['fulls'].$imagelist[$i] .'" title="'. $imagelist[$i] .'" rel="lightbox" target="_blank">';
- Go down to about line 353 and include lightbox.js and its CSS in the page header (it's normal HTML down there).