Photo Gallery with Drupal

This post covers how to make photo gallery in drupal 7

Core Modules required:

  • field
  • field storage
  • field ui
  • file
  • image
  • overload (not necessary but make better experience)

Other Modules

Creating Multiple Photo Galleries

1. Create Content Type – Photo. The fields added are image, a little description and title in our case.
2. Configure image field for colorbox. In ‘manage display’ select format ‘colorbox’ with following settings:

  • Content Image style = thumbnail
  • Colorbox image style = large
  • Gallery = per page gallery
  • This are the ‘full content’ settings

3. Create Content Type – Gallery
4. Add new field of type ‘Entity Reference’ for the content type – Gallery.
This field used to able select photos that is assigned to a Gallery

  • Set Number of values unlimited so as all photos assigned to the gallery got to be displayed
  • For setting ‘Entity Selection’, choose the content type ‘Photo Page’

  • Under ‘Manage Display’ select Format to be ‘Render Entity’. Make sure that this setting is also for ‘Full Content’ and not only ‘Default’ configurations

Note: I went back and updated Teaser for the Photo Page Content type. Afterwards, updated the gallery new field to use ‘Teaser’ instead ‘Full content’ when rendering photos. It provided more flexibility while keeping the Photo page full content as needed.
5. Assigning Photos to the Gallery
From any galleries page, select photos that are associated with the gallery. Afterwards, in the gallery page, all of those photos will be rendered. Clicking on any of the images will start the colorbox widget that you enables scroll through all the images. By clicking on title, it will redirect to the photo page itself

Things To Find Out

1. How to display gallery with relationship from photo to gallery?
The above example is when the relationship between Photos and Gallery is in the direction from Gallery to the Photo. However, it may be desireable to specify gallery from the photo page. In another words, have the relationship from photo to gallery and then render those photos in the Gallery. This was covered in the YouTube How To Make Gallery in Drupal 7 but seems incomplete
2. How to reference a view instead photo page in the Gallery page?
In the above example, we referenced to Photo page in the gallery page, however. Instead referencing the photo page, it may be desirable to reference a view that way giving more flexibility. I got stuck when trying to reference view instead of photo page. Here are my steps:
Steps 1-3 the same as listed above
Step 4. Create a view of type – ‘Entity Reference’ named with machine name ‘bildes_galerija’. Make sure select searchable fields at format->Entity Reference list->Settings
Step 5. Reference a view. For content type – Gallery, created new image field as type of ‘Entity Reference’. In the configuraitons under the ‘entity selection’, select ‘view:filter by the entity view filter’.

With this, i anticipated that the photos in the gallery page is going to be render like the view specified, however. it render the same way as it did when referencing Photo Page.

Useful Links:

Leave a Reply

Your email address will not be published. Required fields are marked *