Using Views to Create Image Galleries

The most flexible way to create an image gallery is to use the Views module combined with a CCK content type called 'Image.' (Note: this is NOT the same content type that is automatically created when you install the Image module. In fact, this method is not compatible with having the Image module installed.)

First, you will need to download and install the following modules if you don't already have them installed: CCK, image field, image cache, views, views bonus pack (optional), and thickbox (optional).

Next, create a content type called 'Image.' This content type should consist of a title and an image field. You can have description (body) field if you want one.

Then you'll need to set-up the dimensions of your image thumbnails. Image cache allows you to automatically create derivations of your images that are cropped, resized, and/or scaled to whatever dimensions you wish. Go to Administer->Site Configuration->Image cache. First, you'll need to name your new preset. For example, I usually use the name 'thumbnail.' Then, I set the action to 'scale.' This will resize the image without distorting it, but you'll need to start with an image that already has the right dimensions. (I generally go with square images since they look better in a gallery if they are a uniform size.) Once you've created your preset, any images you upload will automatically have a thumbnail made.

Next, you need to create the gallery itself. The gallery is actually a view. Create a new view that only displays published image nodes. If you only want thumbnails with no text, only choose the image field under the fields to display section and have it display 'thumbnail as link'. If you installed the views bonus pack, you can create a grid view. By default, it will be four across, so under number of nodes to display, make sure it's divisible by four. If you didn't install the views bonus pack, you can still display images in a list or in a table.

Once you submit your new view, you'll see a gallery of thumbnails each linking to the actual image node for each image.

If you installed thickbox, you can make this basic gallery a bit more fancy. For the image field, have it display as 'Thickbox: thumbnail' instead. Now when one of the thumbnails is clicked, a javascript pop-up will display the full image.

You can further customize your gallery using Drupal's taxonomy. For example, you could have the gallery view take a parameter of a taxonomy term, and have separate galleries for individual categories.