0

I have embedded youtube video in an article using media+media_oembed+media_internet modules.Media(my field) is a field collection item with two fields - media and caption field.I have custom themed(necessary for my custom bootstrap template) media using theme functions according to file type whether it is an image or video.For image i have used picture module and displayed it as below.This is written in the theme_preprocess_field function.:

$row[$field_name][] = field_view_field('field_collection_item', $entity, $field_name,$display = array('label' => 'hidden','type' => 'picture','settings' => array('picture_group' => 'main_story_image','fallback_image_style' => 'w555xh372', 'image_link' => '')), $langcode = NULL

When i try to display embedded youtube video using the code below i get an icon and a filename with a link.

$row[$field_name][] = field_view_field('field_collection_item', $entity, $field_name, $display = array('type' => 'media_oembed'), $langcode = NULL);

How do you find out the correct formatter for the media_oembed module? I got the media_oembed from media_oembed/themes/media_oembed.theme.inc.

0

First of all i got all the default displays in my drupal site using the function : field_info_formatter_types().Since media is a file entity, the formatter should be file rendered.Then i had to give the file view mode in the settings array to show the way i wanted it.I created a custom view mode called article_page(machine name) and added oembed formatter.Here is the final code.

$row[$field_name][] = field_view_field('field_collection_item', $entity, $field_name, 
            $display = array('type' => 'file_rendered','settings'=>array('file_view_mode' => 'article_page')), $langcode = NULL);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.