I've been looking for this for a few months now and I've never found the answer. Checked the IRC channels a thousand times and every Google result, so this is my last resort.

Is it possible to, given the field information for a Media: Youtube file, display the video manually in a template file?

The image in attachment #1 (krumo.png) shows my field (http://i.imgur.com/nQQXkQ7.png). It lives in $node. I've tried the following with zero success

<?php print render($node->field_video_link); ?>
<?php print render($node->field_video_link['und']); ?>
<?php print render($node->field_video_link['und'][0]); ?>

<?php print $node->field_video_link; ?>
<?php print $node->field_video_link['und']; ?>
<?php print $node->field_video_link['und'][0]; ?>

I've also tried nearly every possible combination of

<?php print theme('media_youtube_video', $someArrayOfOptions); ?>

including but not limited to (I've also moved these combinations around within themselves):

$someArrayOfOptions = array(
$someArrayOfOptions = array(
$someArrayOfOptions = array(
$someArrayOfOptions = array(

Attachment #2 (yt.png: http://i.imgur.com/eNM7CvQ.jpg) is the closest I've come with every combination:

The play button is not clickable, the video doesn't do anything doesn't play, the space is just to make sure I could see everything.

Please, how can I just print a playable video with a size of my choosing, in a template file?

yt.png1.83 MBB Leg
krumo.png85.88 KBB Leg
Members fund testing for the Drupal project. Drupal Association Learn more


RobW’s picture

Like I answered on the other issue, use <?php print render($content['field_video_link']); ?>. If you want to adjust the size you can make a view mode with custom formatter options. Instructions on that should be in the Media: YouTube readme.

B Leg’s picture

Like I'd mentioned in the other issue: print render($content['field_video_link']); does nothing no matter where you put it.

RobW’s picture

That's odd. Is the field present at all in the node's content variable? You should be able to find it under the Devel Render tab.

As If’s picture

NOTE: Your field may be named something different.
'field_video_link' is just an example.

Devin Carlson’s picture

Priority: Major » Normal
Status: Active » Closed (duplicate)
Issue tags: -custom template
Related issues: +#1916664: Embeding youtube video in templates
Mohamed Hafez’s picture

i have the same problem and the above recommendation solution didn't work