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:
- 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.
- 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.
- 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.
- 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.
- 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.
- 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?