The goal of this tutorial is to give the reader an idea of how to construct a basic/dynamic image gallery from start to finish.
Note: This tutorial is outdated and no longer supported. For the updated/supported version, click here.
the goal of this tutorial is to give the reader an idea of how to construct a basic/dynamic image gallery from start to finish, not to imply that this is the only way, or even the best way to build a gallery; just a simple approach without all the bells and whistles. at the time of writing, this tutorial assumes a version of PHP >= 4.3 and GD 2.
scenerio - okay, so i've got a crap load of images that i need to display in a user-friendly manner, and i know that more images are soon to come. i want to do the least amount of work possible, and when i say "least" i mean that i upload the picture and i'm done. i also want the script to be very portable, because i expect galleries to change often.
plan of action - no databases, there is no reason whatsoever that we can't just use the existing file system to store and retrieve our data. we're going to build a category based system, each folder will be a category, and sub-folders will be sub-categories. when we're viewing images, i want to be able to restrict the amount of images being shown at once, therefore we need to split each gallery into multiple pages, but we'll also give the user an option to view all the images of a particular gallery at once. i don't want to mess with manually creating/deleting thumbnails either so we'll be using the GD library for that. we should be able to easily change how many images display at a time, as well as what size our thumbnails should be.
building an admin interface would more appropriately be built as an extension onto an existing control panel, this way you don't end up with 100 different login screens for each section of your site. so for now we'll just plan on uploading/deleting images the old fashion way, via ftp or whatever your preference. our focus is simply to display.
our gallery will consist of three scripts: - config.php (contains setup information) - images.php (display's our galleries) - imgsrc.php (draws our thumbnails)