6 min read

Install the Photo Gallery Module

The photo gallery in ExpressionEngine is considered a separate module, even though it is included with every personal or commercial ExpressionEngine license. Installing it is therefore very simple:

  1. Log into the control panel using http://localhost/admin.php or http://www.example.com/admin.php, and select Modules from the top of the screen.
  2. About a quarter of the way down the page, we can see the Photo Gallery module. In the far-right column is a link to install it. Click Install.

ExpressionEngine: Creating a Photo Gallery

We will see a message at the top of the screen indicating that the photo gallery module was installed. That’s it!

Setting Up Our Photo Gallery

Now that we have installed the photo gallery module, we need to define some basic settings and then create categories that we can use to organize our photos.

Define the Basic Settings

  1. Still in the Modules tab, the photo gallery module should now have become a clickable link. Click on the Photo Gallery.
  2. ExpressionEngine: Creating a Photo Gallery

  3. We are presented with a message that says There are no image galleries. Select to Create a New Gallery.
  4. ExpressionEngine: Creating a Photo Gallery

  5. We are now prompted for our Image Folder Name. For our photo galleries, we are going to create a folder for our photos inside the images folder that should already exist. Navigate to C:xampphtdocsimages (or /Applications/MAMP/htdocs/images if using MAMP on a Mac) or to the images folder on your web server, and create a new folder called photos.
  6. Inside that folder, we are going to create a specific subfolder for our toast gallery images. (This will keep our article photos separate from any other galleries we may wish to create). Call the new folder toast.
  7. If doing this on a web server, set the permissions of the toast folder to 777 (read, write, and execute for owner, group, and public). This will allow everyone to upload images to this folder.
  8. Back in ExpressionEngine, type in the name of the folder we just created (toast) and hit Submit.
  9. ExpressionEngine: Creating a Photo Gallery

  10. We are now prompted to name our template gallery. We will use the imaginative name of toastgallery so that it is distinguishable from any other galleries we may create in the future. This name is what will be used as the default URL to the gallery and will be used as the template group name for our gallery templates. Hit Submit.
  11. ExpressionEngine: Creating a Photo Gallery

  12. We are now prompted to update the preferences for our new gallery. Expand the General Configuration option and define a Photo Gallery Name and Short Name. We are going to use Toast Photos as a Photo Gallery Name and toastphotos as a Short Name. The short name is what will be used in our templates to reference this photo gallery
  13. ExpressionEngine: Creating a Photo Gallery

  14. Next, expand the Image Paths section. Here the Image Folder Name should be the same name as the folder we created earlier (in our case toast). For XAMPP users, the Server Path to Image Directory is going to be C:/xampp/htdocs/images/photos/toast, and the Full URL to Image Directory is going to be http://localhost/images/photos/toast. For MAMP users on a Mac or when using a web server, these paths are going to be different depending on your setup. Verify these settings for correctness, making adjustments as necessary.
  15. ExpressionEngine: Creating a Photo Gallery

  16. Whenever we upload an image into the image gallery, ExpressionEngine creates three copies of the image—a medium-sized and a thumbnail-sized version of the image, in addition to the original image. The thumbnail image is fairly small, so we are going to double the size of the thumbnail image. Expand the Thumbnail Resizing Preferences section, and instead of a Thumbnail Width of 100, choose a width of 200. Check the box (the one outside of the text box) and the height should update to 150.
  17. ExpressionEngine: Creating a Photo Gallery

  18. Hit Submit to save the settings so far. We will review the rest of the settings later.

We have now created our first gallery. However, before we can start uploading photos, we need to create some categories.

Create Categories

For the purposes of our toast website, we are going to create categories based on the seasons: spring, summer, autumn, and winter. We are going to have separate subfolders for each of the categories; these are created automatically when we create the categories.

  1. To do this, first select Categories from the new menu that has appeared across the top of the screen. We will see a message that says No categories exist. Select Add a New Category.
  2. We are going to use a Category Name of Spring and a Description that describes the category—we will later display this description on our site. We are going to create a Category Folder of spring. Leave the Category Parent as None, and hit Submit.
  3. ExpressionEngine: Creating a Photo Gallery

  4. Select Add a New Category, and continue to add three more categories: summer, autumn, and winter in the same way.
  5. ExpressionEngine: Creating a Photo Gallery

  6. After we a re done with creating all the categories, use the up and down arrows to order the categories correctly. In our case, we need to move Autumn down so that it appears after Summer.
  7. ExpressionEngine: Creating a Photo Gallery

We now have the beginnings of a photo gallery. Next, we will upload our first photos so that we can see how the gallery works.

Upload Our First Photos

To upload a photo to a photo gallery is pretty straightforward. The example photos we are working with can be downloaded from the Packtpub support page at http://www.packtpub.com/files/code/3797_Graphics.zip.

  1. To upload a photo, select New Entry from the menu within the photo gallery module.
  2. For the File Name, click the Browse…> button and browse to the photo spring1.jpg. We are going to give this an Entry Title of Spring Flower. For Date, we could either leave it as a default or enter the date that the photo was taken on. We are going to use a date of 2006-04-22. Click on the calendar icon to expand the view to include a calendar that can be easily navigated.
  3. ExpressionEngine: Creating a Photo Gallery

  4. We are going to use a Category of Spring and a Status of Open. Leave the box checked to Allow Comments, and write a Caption that describes the photo. The Views allows us to indicate how many times this image has been viewed—in this case we are going to leave it at 0. Hit Submit New Entry when everything is done.
  5. ExpressionEngine: Creating a Photo Gallery

  6. We are presented with a message that reads Your file has been successfully submitted, and the image now appears underneath the entry information.
  7. In the folder where our image is uploaded, three versions of the same image are made. There is the original file (spring1.jpg), a thumbnail of the original file (spring1_thumb.jpg), and a medium-sized version of the original file (spring1_medium.jpg).

  8. Now, click on New Entry and repeat the same steps to upload the rest of the photos, using appropriate categories and descriptions that describe the photos. There are four example photos for each season (for example, winter1.jpg, winter2.jpg, winter3.jpg, and winter4.jpg). Having a few example photos in each category will better demonstrate how the photo gallery works.


Subscribe to the weekly Packt Hub newsletter

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here