In a I was telling you how we have used a solution from to come up with a photo gallery well-suited for a client.
A visitor, named , liked it and was interested in the customization that we have made on the design and functionality regarding the grouping or categorizing of different galleries.

As you can see in the screenshot above there are categories just below the actual image and above the thumbnails. This is the new customized functionality. I will try to explain how you can add these.
IMAGE UPLOAD:The uploading functionality involves three files in this solution:
- class.upload.php
- upload.php
- controller_upload.php
An image is chosen and while uploaded a thumbnail is also created.
The image goes into one directory and the thumbnail into another. Both are named exactly the same name to be able to match them in the photo gallery.
class.upload.phpIn the solution provided by E(2) Interactive the image uploader class by Colin Verot is used to upload images. So this file is included and instantiated in the upload controller page to make use of its methods.
upload.php:I have modified the upload interface to be able to choose into which category a photo should belong to. There is also a small addition made so that we can choose to crop an image from either the left side
or the right side. See below:
controller_upload.php:The customization regarding this solution is that I have created one directory for each category. Each directory then contains the two directories for images and thumbnails. So when clicking 'Upload' in the form and posting this request I have added code that checks which category that has been chosen and puts the image and thumbnail in that one instead. So this takes place in the image uploader controller page that is.
To be more precise this file instanties the class 'class.upload.php'. There is some example/skeleton code of this that you get when you download the package. But briefly what I do is that I depending on which category that has been chosen in 'upload.php' set the value of an image directory variable differently. This variable is then used as the inparameter to the Process function the get the handle.
Here are some pieces of code used in the 'controller_upload.php'
/* Include class.upload.php */ include('../include/class.upload.php');
|
/* Decide on which category directory */ if ($_POST['category'] == "Portrait") { $imgDir = "portraitImagesDirectoryPath"; $imgThumbDir = "portraitImagesThumbsDirectoryPath"; } elseif ($_POST['category'] == "Lifestyle") { $imgDir = "lifestyleImagesDirectoryPath"; $imgThumbDir = "lifestyleImagesThumbsDirectoryPath"; }
|
/* Get a handle to the image directory */ $handle->Process($imgDir); // we check if everything went OK if ($handle->processed) {
|
/* Get a handle to the image directory */ $handle->Process($imgThumbDir); // we check if everything went OK if ($handle->processed) { |
THE GALLERY:There is a configuration file which is used by the actual gallery page called 'config.php'. In this one the path to the images ($galleryPath) and the path to the thumbnails ($thumbpath) are defined. I have created new ones here called for example:
-
gallerypathPortrait and
thumbpathPortrait-
gallerypathCommercial and
thumbpathCommercial-
gallerypathArtist and
thumbpathArtistetc. one of these sets for each category and as you might see the gallerypath is the path to the images directory for that category and the thumbpath is the path to the thumbnails directory.
Here is some piece of code from 'config.php'.
$gallerypathPortrait="portraitImagesThumbsDirectoryPath"; $thumbpathPortrait="portraitImagesThumbsDirectoryPath";
$gallerypathLifestyle="lifestyleImagesThumbsDirectoryPath"; $thumbpathLifestyle="lifestyleImagesThumbsDirectoryPath"; |
The categories on the gallery page are links. Each of these links link to the same page but with a different querystring. I.e. for portrait the querystring is
gallery=Portrait. So on the top of the gallery page we first want to check if there is a querystring and in that case which one. If the querystring value for querystring variable
gallery is 'Portrait' then we want to set the
galleryPath and
thumbPath to those specific paths that we earlier defined in config.php.
Here's some example code for that:
require_once "config.php";
if ($_GET['gallery'] == "Portrait") { $gallerypath = $gallerypathPortrait; $thumbpath = $thumbpathPortrait; } |
The category links are also built up a bit differently depending on which querystring the page is loaded with, i.e. if we have querystring 'Artist' like in the screentshot we want that link to be visited. But this is just CSS that you can get at many places.
One more thing is that there are two special cases. The 'Exhibition' category and the 'About' page don't immediately link to a gallery. The about page doesn't link to such at all and the exhibition page is a middle step. What has been done here is that if you choose either of theese a specific div is built up and displayed on the photo's location instead. The links on the Exhibition page are in turn links to the gallery page with querystrings just like a normal category.
But the big and tough job really was to make the website into the specific design that had created and to make that look the same in different browsers. Now for the critics, I am aware of that there are still some minor flaws if you study the solution and I will fix them later on.
Please feel free to post any questions in the comments if you have any.