Drupal Tutorials and Blog Posts

Creating a Photo Gallery in Drupal 7

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

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.

tutuploadsmedia_1331060256061.png

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.

tutuploadsmedia_1331060521185.png

Step 4: Upload the photos

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

tutuploadsmedia_1331060694984.png

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.
tutuploadsmedia_1331060923047.png

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

tutuploadsmedia_1331060942549.png

Step 6: Improve the View

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

tutuploadsmedia_1331060960346.png

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

tutuploadsmedia_1331062354345.png

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.

tutuploadsmedia_1331061075586.png

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.
tutuploadsmedia_1331061159450.png

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

tutuploadsmedia_1331061180084.png
  • At the bottom of the page, choose Scale and crop.
  • Click Add.
tutuploadsmedia_1331062529803.png

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.

tutuploadsmedia_1331061232609.png

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

tutuploadsmedia_1331061251914.png

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).
tutuploadsmedia_1331061400126.png

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.

tutuploadsmedia_1331061620284.png

Comments

 
jaroslav
#1 jaroslav 2012-05-30 13:20

Finally, clear and simple. Thanks, man:)
 
 
Maaaarius
#2 Maaaarius 2012-06-03 13:30

Nice to see a clear, clean and simple example of how to make a gallery using just a few modules. Still, the only way I can make things work is if I use the default image uploader that comes with Drupal. If I use IMCE or manually upload the images using FTP, I'm not getting the thumbnails to show, even when I know they're in the right folder. Maybe the problem is in the way IMCE adds the images, or the HTML code displaying them. The image itself in the post shows fine, but not the thumbnail in the gallery page. I only get links to the original image in my gallery.

Anyway, thanks for a great tutorial.
 
 
rakib
#3 rakib 2012-07-21 19:24

thats seems sound but after choosing Grid format add field button get disappear. any idea?
 
 
Oliver
#4 Oliver 2012-08-09 23:25

@rakib Try this: In your view check that Format > Show is not set to 'content'. Probably want 'fields'.
 
 
Devesh
#5 Devesh 2012-08-23 05:11

Its very nice post, really really helpful.
thanks a lot for the post.
I wanted to have a jQuery image galley, could you plz help me for that.

Thanks
 
 
Muhamed Auda
#6 Muhamed Auda 2012-09-27 03:28

nice realy nice
good
many thanks
 
 
william mulholland
#7 william mulholland 2012-10-05 06:31

Brilliant!! You just saved me a day of research!
 
 
Andreas
#8 Andreas 2012-10-10 19:15

Very useful, indeed.
Just one question: I didn't find a way to display the filename along with the image.
Any ideas?
 
 
Avitohol
#9 Avitohol 2012-11-02 06:01

Very good description. The gallery is still simpe though.
I need to have multiple galleries, or categories, or nested galleries (whatever you like to call it) like galleries for the different years (2010, 2011, 2012....) with subgalleries for the different months and then the photos.
 
 
Marco uffa
#10 Marco uffa 2012-11-28 16:28

very good tutorial...
understand view and other things..

very thanks!
 
 
Rishabh
#11 Rishabh 2013-01-23 10:18

Thanks..

It was nice.
I want to add lightbox in grid view how it possible. Anyone can help me.
 
 
titta
#12 titta 2013-02-09 17:12

Very good tutorial.
Any suggestion for create a view page with different photo dimension to overwrite the grid layout as in magazine.foxnews.com/ where the grid doesn't appears?
Thanks in advance.
 
 
Byron
#13 Byron 2013-02-15 17:42

I followed instructions to set up gallery. Now that I am adding photos I do not see those photos on my gallery wall. All I see is the image I uploaded during instructions that suppose to show when there are no photos
 
 
Totora
#14 Totora 2013-02-15 20:10

Nice!
Finally a clear and simple Drupal tutorial... it's not easy to find them!
Thanks a lot!!
 
 
Katja
#15 Katja 2013-02-27 04:47

Hey. I have followed your awesome tutorial. And i have been able to get a kind of a gallery with 6 images but the pictures are been placed to the right side instead of in the middle. How do i fix this?
 
 
rohit
#16 rohit 2013-03-13 18:07

how to make everyimage as a url
 
 
Sam
#17 Sam 2013-03-23 12:37

Lol, great to see 'Titanic II' in there. Possibly the worst movie of all time!
 
 
YMVPS.COM
#18 YMVPS.COM 2013-04-26 16:38

I have tried 2 times,these images on homepage still the origin size,and on step 6 finished,it"s same like your shows.I don't know where i'm wrong.
 
 
savitri
#19 savitri 2013-05-15 04:38

Thankyou for ur tutorial, but i have followed all steps. But idk how to show the page "my gallery photo". Is it about the block?
And yes, how to add other efect that use JQuery or CSS.
Please reply me :(
Thankyou so much. :')
 
 
ibrahim
#20 ibrahim 2013-06-14 10:45

thanks for article. i want to learn about how can we change backgroud color from lightgray to white. i try to find but not yet. can we make this "rewrite results" property of views? or we find total views and change it background-color...
any comment make me help.

thanks,
 

Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,244 training sessions in Joomla, Drupal, WordPress and Coding.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Copyright 2013 Open Source Training, LLC. All rights reserved.