標籤:lte turn 解決 attr use scroll height lin ons
轉:https://www.xhsay.com/wp-iframe-handler-youku-tudou.html
雖然WordPress能直接插入優酷、馬鈴薯的視頻但是無法在移動端觀看,於是乎笨笨就開始各種折騰終於找到了合適的解決辦法
另外在說一句支援移動端自適應哦。
函數代碼
在主題函數檔案function.php裡面添加以下代碼即可,保證在最後一個?>之前就好了
//Youkufunction wp_iframe_handler_youku($matches, $attr, $url, $rawattr) {if (wp_is_mobile()) {$height = 200;} else {$height = 485;}$iframe = ‘<iframe width=100% height=‘ . esc_attr($height) . ‘px src="http://player.youku.com/embed/‘ . esc_attr($matches[1]) . ‘" frameborder=0 allowfullscreen></iframe>‘;return apply_filters(‘iframe_youku‘, $iframe, $matches, $attr, $url, $ramattr);}wp_embed_register_handler(‘youku_iframe‘, ‘#http://v.youku.com/v_show/id_(.*?).html#i‘, ‘wp_iframe_handler_youku‘);// Tudoufunction wp_iframe_handler_tudou($matches, $attr, $url, $rawattr) {if (wp_is_mobile()) {$height = 200;} else {$height = 485;}$iframe = ‘<iframe width=100% height=‘ . esc_attr($height) . ‘px src="http://www.tudou.com/programs/view/html5embed.action?code=‘ . esc_attr($matches[1]) . ‘" frameborder=0 allowfullscreen></iframe>‘;return apply_filters(‘iframe_tudou‘, $iframe, $matches, $attr, $url, $ramattr);}wp_embed_register_handler(‘tudou_iframe‘, ‘#http://www.tudou.com/programs/view/(.*?)/#i‘, ‘wp_iframe_handler_tudou‘);//Remove zh_CN Default handlerwp_embed_unregister_handler(‘youku‘);wp_embed_unregister_handler(‘tudou‘);
視頻添加方法
雖然應該都知道但是還是說一下吧 直接在可視化下添加連結就OK
http://v.youku.com/v_show/id_XMTQzOTU2NDg1Mg==.html
WordPress解決優酷、馬鈴薯視頻移動端觀看問題並自適應