Submitted by admin on Fri, 09/06/2019 - 15:16

This tutorial will show you how to create a photo gallery in Drupal 7.

It won't create the world's flashiest or most impressive gallery, but it will work. This tutorial is designed for beginners so that they can understand the key concepts behind creating a gallery in Drupal 7.

Step 1: Install modules

You will need to install and enable the only modules listed below:

Step 2: Create a content type

First, we're going to set up a photos content type. Go to Structure > Content types > Add content type and create a new content type to use for the photo gallery.

Image removed.

Step 3: Add a Photo Field

Now we're going to add an image field to our new content type so that we can actually upload photos. Go to Manage Fields and create a field using the Image data type.

Image removed.

Step 4: Upload the photos

There's a variety of ways to to upload enough photos to fill a photo gallery.

Image removed.

Step 5: Create the View

Go to Structure > Views > Add new view and let's set up the view:

  1. Give your view a name such as Photo Gallery.
  2. Choose to show Content of type Photos.
  3. Check the create a page box.
  4. Choose the Grid display format and choose fields.
  5. Choose a number that will work well in a grid: 12 is the example used here.
Image removed.

Click Continue & edit.
Scroll down and you'll see a preview of your photo gallery. The only thing missing? Photos.

Image removed.

Step 6: Improve the View

Let's go and add the photo to our view. Click add next to Fields.

Image removed.

Search for and select the photos field that you created earlier.

Image removed.

Click Apply (all displays) twice. Now your preview at the bottom of the page will look like the image below. The only thing wrong now is that the images are all different sizes.

Image removed.

Step 7: Resizing the Images

Drupal comes with a way to automatically resize images. Let's see how.

  • Go to Configuration > Image styles > Add style.
  • Enter a name of your new resizing option.
  • Click Create new style.
Image removed.

You'll now see a preview of the image resizing. Currently nothing is happening.

Image removed.
  • At the bottom of the page, choose Scale and crop.
  • Click Add.
Image removed.

Choose how wide and high the photos will be. In our example we have four photos across the page, so we'll choose a width that will allow us to fit four photos in. Click Add effect to finish.

Image removed.

You'll now see a fresh preview of the image resizing.

Image removed.

Now let's go and apply the resizing to our photos.

  • Go to Structure > Views > Photo Gallery > edit.
  • Click Settings next to your photos field. You can now go to Image style and choose the style that you just created.
  • You might also want to uncheck the Create a label box so that the field name doesn't show.
  • Click Apply (all displays).
Image removed.

Click Save to finish your view and go to visit it on the front end of your site. Voila! Your Drupal 7 photo gallery is complete.

Image removed.
Solutions Img