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(
'uri'=>$node->field_video_link['und'][0]['uri'],
'width'=>'700px',
'height'=>'700px',
'autoplay'=>true,
);
$someArrayOfOptions = array(
'uri'=>$node->field_video_link,
'width'=>'700',
'height'=>'700',
'autoplay'=>false,
);
$someArrayOfOptions = array(
'uri'=>$node->field_video_link['und'][0]['uri'],
'width'=>700,
'height'=>700,
'autoplay'=>true,
);
$someArrayOfOptions = array(
'uri'=>$node->field_video_link['und'][0]['uri'],
'width'=>null
'height'=>null
'autoplay'=>true,
);
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?
Comments
Comment #1
RobW CreditAttribution: RobW commentedLike 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.Comment #2
B Leg CreditAttribution: B Leg commentedLike I'd mentioned in the other issue:
print render($content['field_video_link']);
does nothing no matter where you put it.Comment #3
RobW CreditAttribution: RobW commentedThat'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.
Comment #4
As If CreditAttribution: As If commentedNOTE: Your field may be named something different.
'field_video_link' is just an example.
Comment #5
Devin Carlson CreditAttribution: Devin Carlson commentedThis is a duplicate of #1916664: Embeding youtube video in templates.
Comment #6
Mohamed Hafez CreditAttribution: Mohamed Hafez commentedi have the same problem and the above recommendation solution didn't work