I have a content type with some custom fields, and I would like to have a gallery in it, with the images grouped into predefined "categories" - like a "subgallery".

For example, I have a "building" content type, and I would like to categorize the photos of it depending on of which part of the building (house) these photos were made or if they are simply archive photos, etc.: you can think of categories e.g. like "Inside", "Outside", "Archive", "Misc."

I made a drawing to make it clearer:

Content type with galleries and subgalleries

What would be the best way to solve this problem?

Thanks for any kind of ideas!
Ask if anything is unclear.

In the meantime, I found a Media Gallery issue related to the topic: New feature: Gallery containers (other related issues: Hierarchical galleries, Categorizing galleries)

  • IMHO it sounds like job for Node Reference. Did you check drupal.org/project/references? You can try to do it with taxonomy too.
    – Codium
    Aug 11, 2012 at 15:42
  • @drupality: thanks for your answer, but how could I solve that when the end user creates a new content with this custom type, he/she would see an "in-place" uploading opportunity for the galleries? Or what alternatives can you imagine? I also thought about using Media Gallery, but don't have a clue how to apply this for the given task.
    – Sk8erPeter
    Aug 11, 2012 at 15:55
  • If I remember good you can choose reference node from select list (e.g.) on your base node form.
    – Codium
    Aug 11, 2012 at 15:58
  • @drupality: yes, OK, but my problem is that the user will be forced to create a gallery for the given content type separately, and later attach to this content, while this gallery doesn't really make sense on its own. So creating a separate gallery, and later attach to that node would be uncomfortable. :( Or do you know a good solution for that?
    – Sk8erPeter
    Aug 11, 2012 at 16:16
  • Sounds like you need to create custom module with form that allow you to create base node and gallery at once. Is this want you want?
    – Codium
    Aug 11, 2012 at 18:59

1 Answer 1


I don't know how well exactly this will fit in with your use case, but this is how I'd do it:

  • Create a content type called "SubGallery", add an Image field to it with unlimited cardinality.
  • Create the content type you want to contain the sub-galleries ("Building")
  • Add an Entity reference field to the "Building" type that references an unlimited number of "SubGallery" nodes.
  • Choose "Inline Entity Form" as the widget for that field, which will allow users to create the "SubGallery" content types within the same form as the "Building".

You can make use of the standard node title field for the name of the sub-gallery, or you might add a vocabulary called "Gallery Type", and add a field referencing that to the "SubGallery" content type. Then when your users add a new sub-gallery via the inline edit form, they can choose one of your pre-defined gallery types to associate with it.

If you do add the vocabulary and no longer need a node title for the sub-galleries,you could use Automatic Nodetitles to fill it in automatically and hide it from the users.

  • Hi Clive, thanks for your answer and sorry for the late feedback. So, I have Entity Reference 7.x-1.0-rc3 and Inline Entity Form 7.x-1.0-beta3 installed. I created the "SubGallery" content type with an image field: i.imgur.com/HXoLZ.png. Then I created a "Building with subgalleries" content type with an Entity Reference field: i.imgur.com/e0Kxm.png. Here are the field settings: i.imgur.com/vOCci.png. BUT, when I try to create a node of the type "Building with subgalleries", the entity reference field doesn't show up: i.imgur.com/wA4pn.png. But why?!
    – Sk8erPeter
    Aug 16, 2012 at 10:29
  • Hmm that's odd, if you add a field it should definitely show up on the entity edit form. Could you try changing the widget to 'Image' instead of 'Media Selector' just to rule out any issue with that?
    – Clive
    Aug 16, 2012 at 10:51
  • I tried that, changed the widget type to the regular Image: i.imgur.com/fg1Rb.png, but unfortunately the result is the same, the reference field doesn't show up. :( BUT after creating a SubGallery node, and changing the entity reference widget to e.g. "Select list" like this: i.imgur.com/h82KT.png, it shows up on the node creation form: i.imgur.com/ZBZ9S.png. But this way I can only reference existing nodes. So now it seems to me that Inline Entity Form doesn't work this way... I hope I'm not right! Any ideas? Have you tested it this way?
    – Sk8erPeter
    Aug 16, 2012 at 11:19
  • Just for testing, I installed Drupal Commerce, put a "Product reference" field in a test content type, set "Inline Entity Form" as a widget (like in the screencast), and with it, a product can be created "on-the-fly" without a problem. But unfortunately it seems like it doesn't work with "regular" entities like my "SubGallery"... So we are back again where we started... :( Do you have any alternative ideas? (or maybe a correction for the problem with Inline Entity Form)
    – Sk8erPeter
    Aug 16, 2012 at 13:42
  • +1. UPDATE: I found this issue: drupal.org/node/1713088, so others had similar problems like me; this problem seemed to have been solved in the Inline Entity Form 7.x-1.x-dev version, BUT I still have a problem: I activated Automatic Nodetitles like this: i.imgur.com/bzT9L.png, which is correct (tried "separately", and works fine), but on the building node creation form, the title still appears, and while validation, I get this "mysterious" error: i.imgur.com/xgUgZ.png (mysterious, because I don't know which field is missing...).
    – Sk8erPeter
    Aug 17, 2012 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.