Youtube视频


第一步:把以下代码放入couch/addons/kfunctions.php里

<?php
$FUNCS->register_shortcode( 'iframe', 'iframe_handler' );
function iframe_handler( $params, $content=null ){
global $FUNCS;
extract( $FUNCS->get_named_vars(array(
'src' => '',
'width' => '100%',
'height' => '500',
'scrolling' => 'no',
'frameborder' => '0',
'marginheight' => '0'
), $params) );
$html =<<<EOS
<iframe src="$src" title="" width="$width" height="$height" scrolling="$scrolling" frameborder="$frameborder" marginheight="$marginheight">
<a href="$src" target="_blank">$src</a>
</iframe>
EOS;
return $html;
}

 

第二步:在模板里加入字段:无论是B站或者youtube视频都可以

<cms:editable type='text' name='pro_video' label='youtube视频' order='9'/>

第三步:后台填入代码:只需要填入红色部分到后台,Youtube也是同样处理

看下B站的嵌入代码:<iframe src="//player.bilibili.com/player.html?bvid=BV1LF4m1V7bF&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

youtube嵌入代码:

<iframe width="560" height="315" src="https://www.youtube.com/embed/Lr1CLcGF8sk?si=Xhi81nWY0SLe7FhG" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

第四步: 前台调用代码

<cms:do_shortcodes>[iframe src="<cms:show pro_video />" style="width:100%; width: 450px" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen]</cms:do_shortcodes>