Why?

Client wanted to display YouTube videos on website. So we created a content type that utilizes media_youtube. We also built a View which shows the YouTube preview thumbnail, configured through File Entity. Client wanted the thumbnail to link to the referencing content, which was not supported.

What

This switches the field formatter to use theme_image_formatter() and adds the "Link to" option on the file entity Manage Display for the preview image option.

There is one issue: the entity object passed does not represent what kind of entity it is. I had to hard-set 'node' as the entity type for entity_uri, effectively stopping "Link to File." Not sure if anyone knows of a workaround, but I was not able to find much of one without digging deeper into how the entity is passed to the format handler.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SocialNicheGuru’s picture

Notice: Undefined property: stdClass::$referencing_entity in media_youtube_file_formatter_image_view() (line 241 of media_youtube/includes/media_youtube.formatters.inc).
Notice: Undefined property: stdClass::$referencing_entity in media_youtube_file_formatter_image_view() (line 242 of media_youtube/includes/media_youtube.formatters.inc).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7751 of drupal-7/includes/common.inc).

SocialNicheGuru’s picture

Status: Needs review » Needs work

I made the issue update in #1
Not quite sure how it got entered as someone else.

Notice: Undefined property: stdClass::$referencing_entity in media_youtube_file_formatter_image_view() (line 241 of media_youtube/includes/media_youtube.formatters.inc).
Notice: Undefined property: stdClass::$referencing_entity in media_youtube_file_formatter_image_view() (line 242 of media_youtube/includes/media_youtube.formatters.inc).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7751 of drupal-7/includes/common.inc).