php – 如何在Drupal 7中的模板中呈现Youtube缩略图
发布时间:2020-12-13 17:28:53 所属栏目:PHP教程 来源:网络整理
导读:我正在使用以下模块: 媒体 media_youtube 样式 并希望在模板(.tpl)中呈现Youtube视频的缩略图.我应该使用哪个主题功能和什么参数? 我最好的女孩会像: $my_media['style_name'] = 'unlinked_thumbnail';print theme('file_styles',$my_media); 其中$my_med
我正在使用以下模块:
>媒体 并希望在模板(.tpl)中呈现Youtube视频的缩略图.我应该使用哪个主题功能和什么参数? 我最好的女孩会像: $my_media['style_name'] = 'unlinked_thumbnail'; print theme('file_styles',$my_media); 其中$my_media是一个包含fid,uri,filename,filemime等的数组. 由于我对Drupal很新,所有我对模块源代码的尝试都失败了.我觉得我已经尝试了所有可能的youtube和styles模块中定义的风格名称组合,而没有得到任何输出. 视频本身的渲染可以很好的使用 print theme('media_youtube_video',$my_media); 你们怎么做?
在media_youtube模块代码中挖掘出一个功能,将在包含/ media_youtube.formatters.inc中的media_youtube_file_formatter_image_view()中为您构建.您可以使用以下代码来呈现缩略图:
// Make sure the correct include file is loaded module_load_include('inc','media_youtube','/includes/media_youtube.formatters.inc'); // Load the file $file = file_load($my_media['fid']); // Set up the settings array with your image style $display['settings'] = array('image_style' => 'unlinked_thumbnail'); // Get the render array for the thumbnail image $image_render_array = media_youtube_file_formatter_image_view($file,$display,LANGUAGE_NONE); // Render it print render($image_render_array); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |