如何在YII2 DetailView小部件中渲染youtube视频 [英] How to render youtube video in YII2 DetailView widget
本文介绍了如何在YII2 DetailView小部件中渲染youtube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在网站前端显示您的视频.管理员可以从网站后端的嵌入式代码中提供You-tube源.我想在查看页面上预览.以下是我尝试过的代码,但它按原样显示iframe代码(我知道这不是正确的方法)
I'm displaying you-tube video on front end of the website. Admin can provide the you-tube source from embedded code from Site back end. I want to have a preview on view page. Following is the code I tried but it is displaying the iframe tags as it is (I know this is not the right way)
[
'attribute'=>'source',
'value' => !empty($model->source) ? '<iframe class="embed-responsive-item" src="'.$model->source.'" frameborder="0" allowfullscreen></iframe>' : NULL,
],
图像格式是否有类似的东西:
is there any thing like it has for image format:
[
'label'=>'Image',
'attribute'=>'userInfo.image',
'format' => ['image',['width'=>'100','height'=>'100']],
],
推荐答案
格式化html
或raw
将为您提供帮助.
Format html
or raw
will help you.
[
'format' => 'raw',
'attribute'=>'source',
'value' => !empty($model->source) ? '<iframe class="embed-responsive-item" src="'.$model->source.'" frameborder="0" allowfullscreen></iframe>' : null,
],
这篇关于如何在YII2 DetailView小部件中渲染youtube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文