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.
If you’re still using Drupal 6, we have a tutorial for you also.
Step 1: Install modules
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.
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.
Step 4: Upload the photos
There’s a variety of ways to to upload enough photos to fill a photo gallery.
Step 5: Create the View
Go to Structure > Views > Add new view and let’s set up the view:
- Give your view a name such as Photo Gallery.
- Choose to show Content of type Photos.
- Check the create a page box.
- Choose the Grid display format and choose fields.
- Choose a number that will work well in a grid: 12 is the example used here.
Click Continue & edit.
Scroll down and you’ll see a preview of your photo gallery. The only thing missing? Photos.
Step 6: Improve the View
Let’s go and add the photo to our view. Click add next to Fields.
Search for and select the photos field that you created earlier.
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.
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.
You’ll now see a preview of the image resizing. Currently nothing is happening.
- At the bottom of the page, choose Scale and crop.
- Click Add.
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.
You’ll now see a fresh preview of the image resizing.
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).
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.