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.
George Cassie discovered this code in theme_media_gallery_collection_thumbnail():
$link_vars = array();
$link_vars['image'] = $image;
$link_vars['link_path'] = 'something';
$link_vars['classes'] = 'media-gallery-thumb';
$output = '<div class="media-gallery-item-wrapper">' . theme('media_gallery_item', $link_vars) . '</div>';
return $output;
The link path is set to 'something'... huh?
It looks like in our default configuration, this code never gets reached for some reason, and the bug doesn't get triggered. But if you try to use the "Collection thumbnail" formatter somewhere other than the default, you not surprisingly get broken links on your thumbnails.
Comment | File | Size | Author |
---|---|---|---|
#4 | media-gallery-collection-992634-4.patch | 1.63 KB | David_Rothstein |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedComment #2
effulgentsia CreditAttribution: effulgentsia commentedCorrect. theme_media_gallery_teaser() has this code:
Which circumvents theme_media_gallery_collection_thumbnail() from being called for the teaser view mode.
I agree that this is a bug. We currently assume, but don't enforce, that "collection thumbnail" is the formatter used in "teaser" display, that "block thumbnail" is the formatter used in "block" display, and that "gallery thumbnail" is the formatter used in other displays. We need to either prevent the administrator from changing this, or else make our code not assume this.
Comment #3
NPC CreditAttribution: NPC commentedHi, a somewhat unrelated question, but looking at the response of @effulgentsia in #2, where are these formatters configured? They don't match the names of the "imagecache" (whatever they're called now :)) presets that I am seeing. And the field type is not File, it is "Multimedia asset", so I must be missing something important.
Sorry again that I am posting it here, but I try to understand how formatters are applied, and how to change them to match the required dimensions.
UPDATE: Ah, found it, looks like this is an additional wrapper around the image, found here: /admin/config/media/types/manage/image/display. May be this will help someone else find it, too.
Comment #4
David_Rothstein CreditAttribution: David_Rothstein commentedHere's a patch that at least stops the bleeding, by making theme_media_gallery_collection_thumbnail() behave like theme_media_gallery_block_thumbnail() by default.
There's definitely more that we could/should do here (discussed in the code comments), but this ought to be good enough to fix the immediate bug.
Comment #5
effulgentsia CreditAttribution: effulgentsia commentedCommitted #4 to 7.x-1.x.
Re #3: All the configuration wrappers involved in getting Media to display is indeed confusing. You can browse the Media and Styles project issue queues to get a sense of some of the difficulties people are running into. There's some recent (post-beta4) work in the Media module that aims at simplifying it, but Media Gallery is not yet compatible with that, but we're working on it. If you're interested in more background (and it's okay if you're not), I posted a write-up related to this in #1086958-25: Switch from Media Entity to File Entity.