I would very much like the ability to create containers for galleries, for instance a container named people which could contain the galleries; friends, family and others. A sort of hierarchy for galleries is what I want, so that not all galleries are sorted and shown on the same page. I want to be able to categorize galleries, separate them and put them into groups.

I hope my description is understandable.

Best regards,

Members fund testing for the Drupal project. Drupal Association Learn more


JacobSingh’s picture

Hi @Ao, thanks for being so active in the issue queues! We actually built it to work this way from the start, but for UX reasons, decided to limit it to one "Galleries" page. This can be undone though. The galleries themselves are nodes, and there is a "Gallery collection" vocabulary with one term, and all your galleries are currently given that term. So you could create additional terms in Gallery collection and end up with multiple collections. But you might have to code dive a bit to free up the interfaces. IT would be nice to have a switch to go between those who want just one page of galleries and those who want several.

Simplicity vs extensibility is always a tough one :)

Aonoa’s picture

He he, my pleasure. I'm very happy to hear this functionality has been there from the start; now to find it. :-p I agree that with some sort of switch, it would be both simple and flexible at the same time. :-)

Best regards,

Aonoa’s picture

I have found some code related to this in media_gallery.module:

Changing the following to TRUE gives a drop down menu for selecting which gallery term any given gallery should be a child of.

 835   // Hiding this field because we only support a single collection at the moment.
 836   $form['media_gallery_collection']['#access'] = FALSE;

Disabling the following function enables us to access the media gallery taxonomy, yay!

1218 /**
1219  * Implements hook_form_FORM_ID_alter().
1220  *
1221  * Used to hide the gallery_collections taxonomy admin screens.
1222  */
1223 function media_gallery_form_taxonomy_overview_vocabularies_alter(&$form, &$form_state) {
1224   $gallery_collection_vid = variable_get('media_gallery_collection_vid');
1225   unset($form[$gallery_collection_vid]);
1226 }

I found some more useful bits of code. Setting these to TRUE will let us change relations for, and delete 'Gallery collections' terms.

1194   $form['relations']['#access'] = FALSE;
1195   $form['actions']['delete']['#access'] = FALSE;

After making these changes, I've created a new term as a child of the original "Galleries" and attached a gallery to it, but so far the new collection is invisible.. I had hoped children terms would be displayed in some manner or other when viewing the parent page.

I would appreciate some advice, but I will keep digging around. :-)

Best regards,

compsyguy’s picture

I was wondering something else about this... would it be possible to have nested galleries? I'm really interested in the drag and drop ordering, and I was hoping to have the ability to drag and drop images in one gallery to sub-galleries.

Not sure if this is the right place to ask, but it sounded like it was about the right place...

Anyways, I really like this module, and I'm hoping to get some use out of it!

wothor’s picture

Hi Ao, Media Gallery Team,

First of all - great work - loving this module!

Ao, as you said, the new child container is for the moment invisible (following your steps). Did you have a chance to have a look into this?

I'm trying to find something myslef, but tbh I am a total noob at this.... just starting my adventure. :P

Will keep you updated if anything changes.

Kind reagrds,

Aonoa’s picture


I'm afraid I have not had time to progress on this, but it's nice to know we're more people wanting this feature. I will update as well if I come up with something. :-)

Best regards,

Jackinloadup’s picture


KirstenLangholz’s picture

Hello my fellows,

I am also in need of this feature and as my site is supposed to go live end of April, in some sort of hurry. I will look into your solution Ao on the weekend and let you all know what came out on Monday.

In case somebody comes up faster with a solution, I will not blame him/her ;)

Taxoman’s picture

It would be great if it was possible to alter all such true/false states directly from the admin pages.

anavarre’s picture


elgandoz’s picture

interesting feature, subs

jaka’s picture

I love the feature, since there should be a hundred galleries in no time for a community website. It is good to have personal galleries as well.

jaka’s picture

I love the feature, since there should be a hundred galleries in no time for a community website. It is good to have personal galleries as well.

riversidekid’s picture


I have about 10,000 photos in approximately 230 galleries on Drupal 6 with the Image module alone. Without the ability to do nested sub galleries I'm stuck on Drupal 6 forever! Although I like to offer notification when images are uploaded to a particular gallery, and currently I do this with the subscription module on a particular taxonomy. I have just started looking at Drupal 7 and it doesn't look like it's "gallery friendly" just yet, unless I've missed something!

ansorg’s picture


Interesting topic, I was wondering myself what this hidden "Gallery collection" taxonomy would be useful for.

Aonoa’s picture

@riversidekid: With for example a block and a view, you can notify your users of new media that's added to the gallery when using this Media Gallery in D7. =)

Best regards,

riversidekid’s picture

Ao: Thanks for the suggestion, but I'm a bit at a loss. By "notify" I mostly email and RSS feeds. By block and view it sounds like you're plan puts new content on a page. I want to reach out to people to tell them to come back to the site when it's updated; I have many users who are all anonymous to my site, but use RSS feeds to keep up with a specified album or sub album.

Can a block and a view do RSS and/or email notifications in Drupal 7?

kerala’s picture


tomasbedrich’s picture

no progress yet?

jmesam’s picture


dafeder’s picture

The ideal think, it seems to me, would be to introduce a new view style of some kind that could show galleries grouped by anything one wanted.. displaying the first image thumbnail with the "stack" background.

dafeder’s picture

Actually, doing a teaser view of galleries almost accomplishes this. You just don't get the cool mouse-over titles, and the images expand to the full width of their parent element... I imagine there's some way to control that in a theme function but I haven't looked into it yet.

juliangb’s picture


DdR’s picture

+1 subscribing
Would be great if we get this feature working, let's keep digging ;-)

SophieG’s picture

Ok here is what i've done :
When you use Taxonomy Manager, no need to change the code to TRUE for the visibility of the vocabulary in the admin taxonomy management.
So i've added two child terms.
I have changed the possibility for the user to select a term from this vocabulary (for me photos or videos) :

// Hiding this field because we only support a single collection at the moment.
   $form['media_gallery_collection']['#access'] = FALSE;

And i have added two items to my menu, just as the Term Galleries has been added (Link name : Taxonomy term and path taxonomy/term/13 : path to one of my children term of Gallery)
Now, when i go to Galleries : all the types of galleries
And if i go to Photos : only photo ones...

Hope it can help somebody !!

b_ruben’s picture

@JacobSingh, is there possibility to provide requested feature as a patch for beta6?

thinkdrupal’s picture

I did what AO mention in #3 and I'm able to see multiple collections. Each collection has galleries. For example.....I have an image collection and a video collection. Everything seems to work.......except you can not control the layout (# of columns or # of rows) separately for each collection. Both use the same settings. Not a big deal right now. However, i need a solution for that. Why was multiple collections disabled in the first place?

kifuzzy’s picture


Bojhan’s picture

Priority: Normal » Major

It does seem a tiny bit wierd to not have this in a media gallery, simplicity sure - but this is standard functionality for any gallery.

Upgrading to major as from the comments it seems to be a major missing feature. And my own bias, that I can't do anything with my own gallery :( now. As there is no functionality to show containers and their childs.

Taxoman’s picture

#29: second that. Standard functionality.

Per Jansson’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta6

This will be my first post ever!
I am using media gallery for a quite active customer who is adding a gallery every other day. Initially I had self-made taxonomy (still live) in a new vocabulary to filter the galleries and then showing in Views - I got most things to work but not the drag and drop sorting of albums and I was puzzled about the fields in the Gallery Content Type talking about taxonomy terms but no where to find them.

So thanks to @Ao who brought this up and to @JacobSingh for explaining the hidden functionality!

I have followed the steps of #3 and had it all working pretty soon. The non showing galleries in #3 never happened to me, but I have my terms on the same level as the pre-existing term Galleries and not as children of Galleries.

Further I wanted to allow galleries to show up under more than one term and I did not want all of them to belong to the pre-existing Galleries term.
By changing the Gallery content type and managing fields I could set the Gallery Collection taxonomy term reference to take for instance 10 values instead of 1. This all works well UNTIL I try sorting galleries under the different terms. Not always, but as soon as there is one gallery belonging to more than one taxonomy term. Its worthwhile to be careful with this issue because the way the reordering is built you might end up loosing the sort order for some 100 galleries, if you have that many sorted.

The fix for this is the following:
The table holding the sorted galleries is media_gallery_weight, easy to check.

In the file
media_gallery.pages.inc line 184 to 208 approx we find the following function for reordering galleries

 * Reorder a gallery collection.
function media_gallery_reorder_collection($collection, $order) {
  // Get a complete ordered list of the galleries in this collection.
  $galleries = db_query('SELECT ti.nid FROM {taxonomy_index} ti LEFT JOIN {media_gallery_weight} mgw on ti.nid = mgw.nid  WHERE ti.tid = :tid ORDER BY mgw.weight ASC, ti.nid ASC', array(':tid' => $collection->tid))->fetchCol();
  // Sort the list.
  $galleries = _media_gallery_reorder($galleries, $order);
  // Resave gallery weights for the entire collection.
    ->condition('tid', $collection->tid)
  $query = db_insert('media_gallery_weight')
    ->fields(array('tid', 'nid', 'weight'));
  foreach ($galleries as $weight => $nid) {
      'tid' => $collection->tid,
      'nid' => $nid,
      'weight' => $weight,
  return TRUE;

Line 189 :

$galleries = db_query('SELECT ti.nid FROM {taxonomy_index} ti LEFT JOIN {media_gallery_weight} mgw on ti.nid = mgw.nid  WHERE ti.tid = :tid ORDER BY mgw.weight ASC, ti.nid ASC', array(':tid' => $collection->tid))->fetchCol();

returns a result that will vioalate the Primary key constraint of media_gallery_weight and when this happens, first your sortorder for the term you are sorting will be deleted and then when inserting the new one it does not work and you get an SQL exception (in the ajax calls), thereby leaving you with a deleted sortorder but not updated. This happens if there are galleries with more than one gallery collection taxonomy term and as soon as the primary key constraint is violated. It does not happen immediately, don't be fooled by it looking smooth.

One way to fix the SQL above is to use SELECT DISTINCT, another is to use the full primary key in media_gallery_weight, nid and tid, in the LEFT JOIN condition, rewriting the left join:
LEFT JOIN {media_gallery_weight} mgw ON (ti.nid = mgw.nid AND ti.tid = mgw.tid) WHERE ...

It works now, but I am messing with the code and that feels a bit unsafe awaiting updates. Happy for any feedback!

carwin’s picture


webankit’s picture


carwin’s picture

Where does the "edit all galleries" page come from?

I've got two terms in the gallery collections vocabulary, and I've uncommented the necessary section to be able to apply the different terms to galleries I create, however I want to change the settings for one of the galleries without modifying the other.

So gallery A is the default, gallery B is the new one. When I hit the "Edit all Galleries" button the settings I change there only apply to gallery A. Gallery B is left untouched.


It turns out what I was looking for was the edit page of the taxonomy term itself. Seems like the "Edit all galleries" page just tacks that on to the form.

Furthermore, I commented out line 194 of media_gallery.module to keep that tab from being overridden. Commenting out the line makes it so that when you "Edit all galleries" you're editing the correct collection.

BramVanroy’s picture

Definitely need this. Especially to make albums and albums inside albums.

- activities
-- running
-- soccer
-- drumming
- concerts
-- sum41
-- blink182

- activities
-- walking
-- mountaineering
-- paragliding
- concerts
-- dire straits
-- bon jovi
-- toto

This would also make it possible to make one container for movie files and one for photos.

bib_boy’s picture

subscribe! love to see this.

Taxoman’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
AFowle’s picture

I had asked for a similar feature "Hierarchical galleries" in http://drupal.org/node/1273612, which I have now marked as a duplicate. However I want something an end-user can click to "create sub-gallery", not just something the site-designer sets up. I don't think my end users will cope with taxonomy wrangling.

I am trying to move from the Drupal 6 / Gallery 2 combination, which is very good but complex. It offers a sort of gallery breadcrumb for browsing, and ability to choose a highlight for the gallery from one of the daughter galleries or images.

helmo’s picture

I'm posting a patch for ease of testing. it combines the suggestions from #3 and #34.

Sylense’s picture


Bojhan’s picture

Status: Active » Needs review
scampbell70’s picture

Category: feature » support

Hello all I am new to drupal and have been teaching myself for about 3 weeks now, as I build a page for my boyscout troop. I am to create new gallery containers such as 2010 which would contain several albums of the photos taken at various events during 2010 and the same for 2011 and so on.

I posted another thread about this which I did not realize was a duplicate. After following the instructions on post number 3 when I add content | gallery I now see an option that says Gallery collection and has a drop down. the only thing in the drop down at the moment is galleries. I assume that additional galleries I create such as 2010 would appear here but I am unsure how to add these additional gallery collection. Would someone be able to advise me please.

Moloc’s picture

Category: support » feature

#42: Adding a new "gallery collection":
- Goto Administration -> Structure -> Taxonomy
- "list terms" on vocabulary Gallery Collection
or in short: admin/structure/taxonomy/gallery_collections here you can add/edit/remove gallery collections
To make one of them default, change the default value in the specific field of the gallery - content type.

scampbell70’s picture

I think I got it figured out thank you for all the rapid responses

helmo’s picture

Category: feature » support

Do you have all changes from #39, maybe a cache clear...

You could also try the Taxonomy Manager mentioned in #25

Moloc’s picture

Find in media_gallery.module line ~1300

function media_gallery_form_taxonomy_overview_vocabularies_alter(&$form, &$form_state) {
  $gallery_collection_vid = variable_get('media_gallery_collection_vid');

and replace it with

function media_gallery_form_taxonomy_overview_vocabularies_alter(&$form, &$form_state) {
  // $gallery_collection_vid = variable_get('media_gallery_collection_vid');
  // unset($form[$gallery_collection_vid]);

Then you should see it.

I extended the path of helmo:
- add a variable to determine, wheter to show the "gallery collection" or not.
- replaced the admin/config/media/galleries url with a configuration page.
- added some code to catch PHP-Notice messages on deleting taxonomy terms.

scampbell70’s picture


Thank you very much I will try this asap and let you know the results

scampbell70’s picture

I have ran into another strange issue or bug I am hoping you can help me fix. I created two taxonomy terms 2010 and 2011. I created 3 galleries under 2010 and 3 under 2011. I was able to directly link to them and add them to menus and everything was looking great. I noticed however that when I select show title show below on 2010 it refuses to work and only show the title on hover, but when I select show title below on 2011 it works perfectly fine is there a way to fix this?

helmo’s picture

Status: Needs review » Needs work

Cool, a few minor remarks...

+++ b/media_gallery.admin.inc
@@ -5,8 +5,21 @@
+    '#description' => t('Enables the creation of multiple <em>gallery collections</em> and <em>hirarchical galleries</em>.'),

typo: hirarchical => hierarchical

+++ b/media_gallery.admin.inc
@@ -5,8 +5,21 @@
+  if (variable_get('media_gallery_use_multiple_collections', 0)) {

Lets use FALSE as default

+++ b/media_gallery.module
@@ -37,9 +37,11 @@ function media_gallery_file_view_modes() {
+    'description' => 'Configure settings for the gallery module.',

to avoid confusion we'd better name it "Media Gallery module"

+++ b/media_gallery.module
@@ -1268,8 +1273,9 @@ function media_gallery_form_taxonomy_form_term_alter(&$form, &$form_state) {
+  $multiple_collections = (bool) variable_get('media_gallery_use_multiple_collections', 0);

Typecasting wouldn't be needed if the default is changed.

Moloc’s picture

Status: Needs work » Needs review
6.5 KB

Thank you for review.
+ added fixes recommended by helmo (i replaced the 0 to FALSE for better reading. Changing the value in the admin-settings with the checkbox will generate always an integer value of zero or one.)
+ added fixes for delete-access bypass

Check the settings again. Try to clear the cache.
Have you also changed these lines?
Find in media_gallery.module

 190   if (($term = menu_get_object('taxonomy_term', 2)) && isset($term->vid) && $term->vid == variable_get('media_gallery_collection_vid')) {
 191     $tabs = &$data['tabs'][0]['output'];
 192     foreach ($tabs as &$tab) {
 193       if (isset($tab['#link']['path']) && $tab['#link']['path'] == 'taxonomy/term/%/edit') {
 194         $tab['#link']['href'] = 'admin/config/media/galleries';
 195         $tab['#link']['title'] = t('Edit all galleries');
 196       }
 197     }
 198   }

and replace it with

 190   if (($term = menu_get_object('taxonomy_term', 2)) && isset($term->vid) && $term->vid == variable_get('media_gallery_collection_vid')) {
 191     $tabs = &$data['tabs'][0]['output'];
 192     foreach ($tabs as &$tab) {
 193       if (isset($tab['#link']['path']) && $tab['#link']['path'] == 'taxonomy/term/%/edit') {
 194         // $tab['#link']['href'] = 'admin/config/media/galleries';
 195         $tab['#link']['title'] = t('Edit all galleries');
 196       }
 197     }
 198   }

Otherwise you change the values always for the same gallery collection.

Moloc’s picture

Patch in #50 produces a notice on taxonomy-term creation.
This patch fixes that.

Bojhan’s picture

It seems to work for me! I didn't try out deeper hierarchical structures though, I wonder how well that works.

scampbell70’s picture

disregard this post I thought I was patching wrong it turns out there was something else I was missing

Carlos Miranda Levy’s picture

One remaining limitation is that there is no main listing of all gallery containers.
But it can be easily solved by adding an image field to each gallery container and then creating a taxonomy view to display the image and title for each gallery container.

I did this in a test site I'm helping build for a friend:


von_stirliz’s picture

Hi guys,

can someone send me the patched media_gallery.admin.inc file? I have issues with patch command.

Would be greatly appreciated. info(at)da.mg

helmo’s picture

@von_stirliz: http://drupal.org/node/1399218 might be a good starting point for you.

von_stirliz’s picture


I have patched it manually, but thanks.

P.S. I have no access to command line with my hosting :( So no git, no patch, no drush....

milos.kroulik’s picture

You can always patch it on you localhost and upload it. I'm on the same boat.

Aonoa’s picture

Category: support » feature

It is very nice to see that my feature request got this much support, and with the patches people have made I'm hoping we can see this functionality added to Media Gallery soon. How about it, Jacob? Clearly the community wants this added and enabled by default.

Best regards,

triple5’s picture

@ riversidekid #17 on April 25, 2011 at 8:47pm
I would say yes to that, a view can definitely be a RSS feed at least. To get emails from there would be either with views_send module (see also http://drupal.org/node/1323918) or something similar.

Yep, I would love to see this functionality for my video galleries as well, I would like to even dynamically tag the videos and create galleries on the fly from that, so far other things are not working for this...

fabrizioprocopio’s picture


lsolesen’s picture

@fabrizioprocopio Please do not make "subscribe comments". Use the big green button in the upper right corner instead.

RajeevK’s picture

Hello All,

I read much comments here and thought it's matching my requirement.

Let me explain my need -

I want to create a gallery and import any folder from local file to map that with my created gallery. If it can't be done then I want to give a term for all the photos which I am importing from local folder, so that I can shortlist them when I go "ADD MEDIA"...

Is it possible in some way as when I am trying to add media now...all photos are getting listed & it's making me confuse that which I have imported in last and is not appeared in some other gallery..

If any body can help then it will be great help..


lsolesen’s picture

@Rajeevkr You should create a new support issue and not hijack an existing, unrelated issue.

RajeevK’s picture


I thought it's relevant to my issue...

extremely sorry..

borfast’s picture

I applied the patch from comment #51 and it does let me add containers but if a container is inside an existing gallery (i.e., the gallery is the container's parent), it isn't shown. I would expect it to be shown just like any other gallery. Am I missing something or is it not implemented?

Moloc’s picture

#66 borfast: Your wish is not implemented. So feel free to open a new "feature request" issue.

Carlos Miranda Levy’s picture

I applied patch #51 manually to 7.x-1.0-beta8 Jul 6 2012 and it works. :-)

flowbyte’s picture

I'd would be very interested in this. It does seem to be the only thing missing from the module.

Rob C’s picture

When i test this patch on the current dev i get:

media_gallery# patch -p1 --dry-run < enable-gallery-collections-1037002-51.patch
patching file media_gallery.admin.inc
patching file media_gallery.install
Hunk #1 succeeded at 965 (offset -3 lines).
patching file media_gallery.module
Hunk #2 succeeded at 189 (offset -4 lines).
Hunk #3 succeeded at 882 (offset 34 lines).
Hunk #4 succeeded at 1317 (offset 44 lines).
Hunk #5 succeeded at 1337 (offset 44 lines).
Hunk #6 succeeded at 1358 (offset 44 lines).
Hunk #7 FAILED at 1350.

fox_01’s picture

Maybe an idea to extend the new container feature.

Wouldn't it be nice to have the settings like allowed file types etc. configurable per container / taxonomy, so a container personal pictures can have only pictures and public videos only videos and so on?

Carlos Miranda Levy’s picture

Patch 51 by Moloc also works on the 7.x-2.x-dev version except for last hunk.
Just remove that last hunk from patch, apply and then manually remove the lines manually from media_gallery.module.

They are now further down, but they are exactly the same code and you can remove them safely and without doubts.

Once you do this, you have to flush your caches or you will get an error.

Once you flush it, the option for enabling Gallery containers will show at "admin/config/media/galleries".

salvis’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
6.64 KB

Here's a reroll of patch #51 without any changes.

I haven't actually looked at whether it works yet, just rerolled it for 7.x-2.x-dev.

Hetta’s picture

The patch applies nicely.

(Note, the edit gallery page still says "The following settings affect the "All galleries" page, which shows a thumbnail of every gallery created.")

I'm on D7.22 with Media 7.x-2.0-unstable7+38-dev and media_gallery 7.x-2.x-dev.

Hetta’s picture

Status: Needs review » Reviewed & tested by the community
bkat’s picture

I've applied the patch in #74 to 7.x-2.x-dev and it applied with no errors. I've enabled Use multiple gallery collections. I then went to the "Configure gallery collections page" and added a new term as a child of galleries. Let's call it "2013"

I then to some galleries and set them to be in the collection 2013.

When I go back to the galleries page, I don't see any indication of there being a container named 2013 as a child of the main galleries page. The description of "use multiple gallery collections" option says that it enables hierarchicical galleries but I'm at a loss on how to set up a hierarchy of galleries.

Hetta’s picture

bkat: That's actually a taxonomy problem. It should be possible to get taxonomy to display child terms, but alas, I haven't found out how to do that yet. It's certainly a major bug for D7 ... as it worked out of the box for D6.

bkat’s picture

Issue summary: View changes

I'm back at this after a hiatus. I've applied the patch to the current 7.x-2.x-dev and it was clean. In "Configure Gallery Collections" I added 4 collections under galleries and added galleries to each.

While in the gallery collections config, I can click on one of these and see the galleries that I've added to it. However, when I go to the toplevel Gallery, I only see the galleries added to it and not any of the collections that I've added to it.

In #77, Hetta mentioned something about a taxonomy problem. I'm not entirely sure what is meant. Can someone enlighten me on how to browse the gallery hierarchy from the top level?

bkat’s picture

3.32 KB

I just tried something that will work for now. I created a view named subgalleries that takes "Taxonomy term: Parent term" as an argument with the default value coming from the URL.

It filters the vocabulary to be gallery collections and sorts by taxonomy weight. The one and only field is term name (linked) and I display as a grid.

I created a block and configured it to display in the content section for pages "taxonomy/term/*"

So now when I go to my top level gallery, I get a list of its gallery collections. Not perfect but sufficient for now. I'd like the sub galleries to display the number of galleries and pick one of them as an image to display.

I'm attaching an export of my view in case anyone is interested.

Of course I'm still interested to hear if there is a native way to get a gallery collection to display all its child collections in addition to the galleries.

Fogg’s picture


fabrizioprocopio’s picture


fabrizioprocopio’s picture

I just found this module
I'm going to try it. It seems to do what we looking for

fabrizioprocopio’s picture

lsolesen sorry. I did 2 times +1. I really didn't see the following green button. Sorry very much.

Lion.creek’s picture

Hello, is currently a way to sort the gallery into folders? Create subgalerie?

Thank you for answer.
I use 7.x-2.x-dev tar.gz (301.27 KB) | zip (307.41 KB) 2015-Oct-17