Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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";
}
Comment | File | Size | Author |
---|---|---|---|
allow-custom-item-view-themeing.patch | 1.27 KB | jamiecuthill |
Comments
Comment #1
rickvug CreditAttribution: rickvug commentedSubscribe.
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.
Comment #2
bschilt CreditAttribution: bschilt commentedI 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.
Comment #3
bschilt CreditAttribution: bschilt commentedIt 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.
Comment #4
lsolesen CreditAttribution: lsolesen commentedAre you still using the patch
Comment #5
bschilt CreditAttribution: bschilt commentedI did not need to apply the patch.
Comment #5.0
bschilt CreditAttribution: bschilt commentedcode formatting
Comment #6
dman CreditAttribution: dman commentedI 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.
Comment #7
Chris CharltonThe 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
Comment #8
Ludo.RWhich 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.
Comment #9
Chris CharltonI may have been using a dev branch or 2.x, not sure atm which project that was for.
Comment #10
ivnish CreditAttribution: ivnish commented