There are dozens of free photo gallery widgets out there; however, I find that most of them are too busy, too complicated, or just clumsy to use. This is a remarkably simple, easy to use, and lightweight photo gallery created with less than 150 lines of PHP. In addition, unlike many gallery widgets, it can be seamlessly embedded into any place on any page. (see below for an example.)
How it works
SimpleGallery will display all images you place in a specified gallery folder. They will be displayed in lexicographical order by file name. There is no special uploading interface required, no database set up, and no accounts or login. It really couldn't be simpler
Click on a picture to view it individually. You can then navigate the gallery with the arrow buttons or the left and right arrow keys on your keyboard, or click the center grid button to return to the gallery layout.
To add SimpleGallery to your site, simply unzip gallery.zip in the same directory as the page to which you will add the gallery, add the images you want to display to 'gallery/images', and include 'gallery/gallery.php' where you would like the gallery to display:
<?php include "simplegallery/gallery.php"; ?>
Optionally, you can specify any of the following:
- GALLERY_IMAGE_DIR: The folder that holds the images to be displayed. Useful for creating multiple galleries. (default: "simplegallery/images/")
- GALLERY_SRC_DIR: If your gallery folder is not in the same directory as the file which includes the gallery, you must specify its path. (default: "gallery/")
- GALLERY_WIDTH: Width of the gallery (default: "750")
- GALLERY_THUMBS_ACROSS: The maximum number of images in a single row of the gallery view (default: "4")
- GALLERY_GENERATE_THUMBS: Use gd to regenerate thumbnail images (default: "0")
- GALLERY_THUMB_DIR: If gd thumbnail generation is enabled, this is the directory where thumbnails will be stored. (default: GALLERY_IMAGE_DIR."thumbs/")
***WARNING: do not make this the same as GALLERY_IMAGE_DIR or you will overwrite your images.
In fact, there are very few cases in which it makes sense to change this setting. You should probably just leave it alone.
If you have GD Graphics Library installed on your server (GD is usually bundled with PHP), you can enable thumbnail generation. There is absolutely no setup required. Just define GALLERY_GENERATE_THUMBS as "1", and SimpleGallery does all the work. It will automatically generate a new thumbnail image every time you add or update an image in your gallery folder. Simple!
However, if you do not have access to GD or if you don't plan on displaying images that are much more than 1000px wide you can leave thumbnail generation off (this is the default setting.) This is fine for most websites (like mine), for which hi-resolution images are actually just an unnecessary burden on the user. If fact there are some advantages to this. When a user views the gallery without thumbnail generation enabled, all of the full sized images will immediately begin caching on the users computer. This way, the user does not have to wait while each individual image loads while browsing through your gallery.
If you don't know how to shrink images in batches, you can do it here. Or, you can just do what I do, and just download them from facebook. They are just the right size.
Try it out!