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.
Comment | File | Size | Author |
---|---|---|---|
media_youtube with link to in formatter settings.png | 50.74 KB | mglaman | |
media_youtube-use-image-formatter.patch | 2.75 KB | mglaman | |
Comments
Comment #1
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedNotice: 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).
Comment #2
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI 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).