wordpress使用短代码播放优酷,土豆视频支持ios

我以前用的都是知更鸟的段代码播放优酷的视频的,结果这次不行了。

所以我就又捣鼓捣鼓了下找了一段,这个感觉更好用了。

下面说下使用方法吧!

直接放在functions.php面就好了!

//优酷土豆视频播放代码
add_shortcode( 'youku', 'v7v3_youku_shortcode' );
function v7v3_youku_shortcode( $atts, $content='' ) {
extract( shortcode_atts( array(
'width' => '510',
'height' => '498',
), $atts ) );

if(preg_match('#http://v.youku.com/v_show/id_(.*?).html#i',$content,$matches)){
return '<iframe class="v7v3_video" height='.esc_attr($height).' width='.esc_attr($width).' src="http://player.youku.com/embed/'.esc_attr($matches[1]).'" frameborder=0 allowfullscreen></iframe>';
}
}

add_shortcode( 'tudou', 'v7v3_tudou_shortcode' );
function v7v3_tudou_shortcode( $atts, $content='' ) {
extract( shortcode_atts( array(
'width' => '480',
'height' => '400',
), $atts ) );

if(preg_match('#http://www.tudou.com/programs/view/(.*?)#i',$content,$matches)){
return '<iframe width='. esc_attr($width) .' height='. esc_attr($height) .' src="http://www.tudou.com/programs/view/html5embed.action?code='. esc_attr($matches[1]) .'" frameborder=0 allowfullscreen></iframe>';
}
}
//优酷土豆视频播放代码结束

然后在撰写文章的时候,直接写上视频地址就好了!

这里演示下:

土豆

优酷