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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Title: Theme fucntion for the "Collection thumbnail" formatter generates broken links » Theme function for the "Collection thumbnail" formatter generates broken links
effulgentsia’s picture

Title: Theme function for the "Collection thumbnail" formatter generates broken links » Theme function for the "Collection thumbnail" formatter generates broken links when used for any display other than "teaser"
It looks like in our default configuration, this code never gets reached for some reason

Correct. theme_media_gallery_teaser() has this code:

$element['media_gallery_media'][0]['#theme'] = 'media_gallery_file_field_inline';
$image = drupal_render($element['media_gallery_media'][0]);

Which circumvents theme_media_gallery_collection_thumbnail() from being called for the teaser view mode.

But if you try to use the "Collection thumbnail" formatter somewhere other than the default, you not surprisingly get broken links on your thumbnails.

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.

NPC’s picture

Hi, 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.

David_Rothstein’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
1.63 KB

Here'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.

effulgentsia’s picture

Status: Needs review » Fixed

Committed #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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.