Skip to content

Gallery (V2)

Galleries (V2) provide an easy way of tagging photos for display in a lightbox.

This component requires Drupal to function, hence the examples here are not interactive.

Open Full Example
<div class="grid grid--3col grid--centered gallery-v2">
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group1</span></div>
    </div>
  </div>
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group1</span></div>
    </div>
  </div>
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group1</span></div>
    </div>
  </div>
</div>
Open Full Example
<div class="grid grid--2col grid--centered gallery-v2">
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group1</span></div>
    </div>
  </div>
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group1</span></div>
    </div>
  </div>
</div>
<div class="grid grid--2col grid--centered gallery-v2">
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group2</span></div>
    </div>
  </div>
  <div class="grid__item">
    <div class="gallery-v2__item">
      <div class="gallery-v2__thumbnail"><img src="/styles/landscape_medium/public/test-image-landscape.jpg" alt="Test Image" /></div>
      <div class="gallery-v2__caption"><span>Image Caption</span></div>
      <div class="gallery-v2__group"><span>group2</span></div>
    </div>
  </div>
</div>

Gallery V2 requires the colorbox library active on your page to function. Add the gallery-v2 class to a parent container to “enable” the gallery functionality on it. Each photo to be used in a gallery needs the item, and each item has thumbnail, caption, and group divs. The thumbnail contains the image to display on-page. The caption contains the HTML/text that will display under the image in the lightbox. The group defines a group that the image belongs to. You can use multiple groups on the page to offer different galleries. The group name can be any string in the group tag, and every gallery item with that string will display in the same “set” in the lightbox.

  • To provide full-size display of thumbnail images: If the page contains many small images that you want the user to be able to see at full size, then galleries are a good fit.
  • When images are the focus of the page or story: If the focus is on the images, it makes sense to use a gallery.
  • Don’t use for single images: Using the lightbox fox just one image is unintuitive and may be confusing to the end user.
  • Ensure Gallery images have proper alternative text: Galleries provide an optional caption field that can be used to give more information about a photo, but the photo still needs proper alternative text set to describe the image.
ElementDescriptionUsageRequiredMultiple
ItemThe Gallery Item containerWrap the photo and metadata in thisYesYes
ThumbnailThe item’s thumbnail imageUse as you would for in-page display, or a small image in a grid for a gallery collectionYesNo
CaptionThe image’s captionLimit HTML to basic text formatting tagsNoNo
GroupThe item’s gallery groupUse a plaintext string to identify which group of photos the item belongs toYesNo
Key CommandDescription
enterOpen the lightbox gallery for the focused image
leftWhen in lightbox, display the previous image in the gallery
rightWhen in lightbox, display the next image in the gallery
escWhen in lightbox, close the lightbox

This component requires the colorbox javascript library to be installed to function. This is provided out of the box in the UO Cosmic theme.