Hi,

I'm trying to render a youtube video/image into my content. The field in template.php contains

[2] => Array
(
[fid] => 26
[title] =>
[data] =>
[file] => stdClass Object
(
[fid] => 26
[uid] => 1
[filename] => Title of youtube file
[uri] => youtube://v/youtubeuri
[filemime] => video/youtube
[filesize] => 0
[status] => 1
[timestamp] => 1356531088
[type] => video
[rdf_mapping] => Array
(
)

[entity_view_prepared] => 1
)

)

Is there anything I could use like in images, such as

theme('image_style',array('style_name'=>'media_youtube_image','path'=>$media["file"]->uri,'alt'=>$alt,'title'=>$title))

Thanks

Comments

You should use Media: YouTube's built in image formatter. Set up a new view mode for your file types, add the image formatter for the video output, and then use the rendered file for that view mode in your content. For working with view modes, see the Media documentation: http://drupal.org/node/1793548.

Status:Active» Closed (fixed)

Is there any step-by-step tutorial for that? The link you sent me gives some definitions without any examples

Status:Closed (fixed)» Active

Even for the default view mode...how do I use it?

I don't know if it's the proper way, which I would like to know, but the following, which I found in youtube module, worked for me

<?php
$filename
= $media["file"]->filename;
$wrapper = file_stream_wrapper_get_instance_by_uri($media["file"]->uri);
$img_path = $wrapper->getOriginalThumbnailPath();
$link = $wrapper->interpolateUrl();
$img = theme('image',array('path'=>$img_path,'alt'=>$filename,'title'=>$filename));
$vars['my_media'] = l($img,$link,array('attributes'=>array('title'=>$filename,'target'=>'_blank'),'html'=>TRUE,'external'=>TRUE))
?>

This what I have used in template.php

Assigned:symeon.mattes» Unassigned
Status:Active» Fixed

You'll probably want to use file_view_file();

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

I have created a custom block for video. how can i render it using hook_block_view