The media gallery module is currently implemented with a fixed set of view modes for the gallery media field file formatter. As a site developer I want to be able to alter the list of view modes to add my own.

I have had a look at the code and believe this patch will enable the functionality at a basic level.

Example implementation

function mymodule_media_gallery_file_view_modes_alter(&$modes) {
  $modes['mymodule_slideshow'] = t('Gallery slideshow');
}

function mymodule_theme() {
  return array(
    'mymodule_slideshow' => array(
      'render element' => 'element',
    ),
  );
}

function theme_mymodule_slideshow($variables) {
  $element = $variables['element'];
  // do something fancy with the element
  return "<pre>item</pre>\n";
}

Comments

rickvug’s picture

Subscribe.

I'm very interested to hear what the module maintainers think. I really like Media Gallery's architecture and usability (drag and drop ordering for instance) but think there's too many assumptions about what fields users want and how galleries should look. It would be excellent to see fewer assumptions and/or more opportunities to override settings with your own.

bschilt’s picture

I will give this a try today and report back. I need to have my gallery collection thumbnails rendered in a different size/style to fit the design provided.

bschilt’s picture

It turns out that I didn't need to create a new file view mode, I just needed to change the size of the gallery collection thumbnail, and I did it with the help of this post http://drupal.org/node/1231676.

lsolesen’s picture

Are you still using the patch

bschilt’s picture

I did not need to apply the patch.

bschilt’s picture

Issue summary: View changes

code formatting

dman’s picture

Issue summary: View changes

I know it's old, but I also found this limitation today.
I could not find in the UI where the short list of *available* "File view mode" options was defined, as it's not the full set that is available to the rest of my displays. Which is what I'd expected.
I also wanted to use a local (display_suite) variation of the Gallery Media thumbnails (in association with display suite view-mode-per-node switcher etc) and do not want to tromp on the other formats.

I think the extension of a hook as in the code here is nice code, and a non-intrusive addition.
But Ideally, I'd just like to see either all view modes available in the formatter settings there (is there a reason why not?) or a limited and configurable set. Should not require a custom module hook just to enable another mode there.

Chris Charlton’s picture

The image file type admin screen lets you configure Gallery View Modes, which is a separate admin screen from the content type field display. Check out: admin/structure/file-types/manage/image/display/media_gallery_thumbnail

ludo.r’s picture

Which version are you using Chris?

I'm using 1.x and I don't have a page at admin/structure/file-types/manage/image/display/media_gallery_thumbnail.
Not even admin/structure/file-types.

I would like to use a custom view to show all my galleries.

Chris Charlton’s picture

I may have been using a dev branch or 2.x, not sure atm which project that was for.

ivnish’s picture

Status: Active » Closed (outdated)