Creating Image Galleries In Drupal

Creating Image Galleries In Drupal

A few recent clients requested image galleries to feature their projects on their new Drupal websites. Last year, we had similar requests and looked for modules that would meet the client’s requirements, but we could not find anything that worked well enough to keep them happy. I did another search to see if any new modules had come out that would meet the client’s needs, and again, I could not find anything suitable. After consulting with a few Drupal experts, I was lead to believe there are not any. “Build your own gallery,” was the advice given by Dustin Currie, our lead developer.

So I did do it myself with a little help from CCK, ImageCache, Views, LightBox 2, and Taxonomy.

Here’s how I did it:

  1. I created a content type called Gallery Image and added a CCK field for uploading an image. I allowed png, gif, and jpg extensions for this field. This is also where you can set you minimum and maximum file upload sizes.
  2. Next, I created my ImageCache presets. One for the thumbnail view of the image (Scale and Crop 200px X 175px), and the other for the large view of the image (Scale - width 600px). This really harnesses the power of ImageCache. You can upload an original image that is 2,100 pixels wide and ImageCache will automatically do all of the cropping and scaling for both of your images. No need to create two separate images in Photoshop.
  3. The next step is to configure the Lightbox 2 module. Under Advanced Settings, I changed the color and opacity of the overlay to get rid of the default Lightbox 2 look and more closely match the client’s theme.
  4. Now, we move on to Views. I set up three filters - Node: Published Yes, Node: Type = Gallery Image, and Taxonomy: Term. I made my fields Content: image Lightbox2: gallery_thumb->gallery_large (This setting automatically makes the thumbnail image expand into the large image using Lightbox 2) and Node:Title. Under Basic settings, I made the style Grid with 3 columns, and a horizontal alignment.

  5. I created a Vocabulary named Projects and checked off Gallery Image on the Content Types list. Next, I added terms. In this case I made the name of each project the client wanted to feature in a gallery a term.
  6. Back to Views to set up page displays for each gallery. The only thing to change is the Taxonomy Term under filters. Just make sure each Taxonomy Term has its own page display. Under Page settings give each gallery a path and assign it to a menu. In this case, I just made Projects menu and displayed in a block in the sidebar.

I wasn't happy that I couldn't find a module that I could just install and it would do everything I wanted; however, building the gallery myself proved to be a great learning experience and ended up being much easier than I had thought. As with anything Drupal, there are probably other, possibly better ways to build galleries, but this one works for me and the client is happy.

Has anybody out there found a good gallery module or recipe?

Related Reading

Related Posts

Using Image Fields in Drupal 7

Tom McCracken
Read more

Creating content types in Drupal 7

Tom McCracken
Read more

Creating Custom Google Analytics Events In Drupal

Tom McCracken
Read more

Creating and Growing a Drupal User Group

David Hahn
Read more

OE Pro: Creating Custom Content Layouts With Drupal 7

Brent Bice
Read more

Design Tools For Creating Pretty Drupal Sites

Brent Bice
Read more