WordPress解决优酷、土豆视频移动端观看问题并自适应
2017-09-20 08:41
302 查看
转:https://www.xhsay.com/wp-iframe-handler-youku-tudou.html
虽然WordPress能直接插入优酷、土豆的视频但是无法在移动端观看,于是乎笨笨就开始各种折腾终于找到了合适的解决办法
另外在说一句支持移动端自适应哦。
虽然WordPress能直接插入优酷、土豆的视频但是无法在移动端观看,于是乎笨笨就开始各种折腾终于找到了合适的解决办法
另外在说一句支持移动端自适应哦。
函数代码
在主题函数文件function.php里面添加以下代码即可,保证在最后一个?>之前就好了//Youku function 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'); // Tudou function 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 handler wp_embed_unregister_handler('youku'); wp_embed_unregister_handler('tudou');
视频添加方法
相关文章推荐
- 解决移动端H5海报滑动插件适应大部分手机问题 手机端高度自适应
- firefox播放优酷,土豆视频,出现 “浏览器兼容性问题,视频不能播放了”的解决方法
- 关于表格高度在移动端某些应用内高度设置为百分比后不能被压缩问题的解决
- 解决wordpress3.5更新插件和主题失败的问题
- 一些在使用wordpress会出现的问题解决方法:
- 如何选择机器学习的算法及适应解决的问题
- 解决wordpress下编辑jpg格式图片的问题
- 完美解决wordpress邮件链接无效的问题
- 解决移动端overflow:hidden无效的问题
- 【解决】移动端设备·横竖屏时页面内容字体大小调整的问题
- 解决 WordPress 占用内存不断上升的问题
- unity在移动端的字体不能调节大小问题解决办法
- 解决extjs grid 不随窗口大小自适应的问题
- 关于移动端css+js解决遮罩问题方法。
- 移动端兼容性问题解决方案
- PrismJs 语法高亮 解决移动端代码块无法横向滑动的问题
- 完美解决WordPress摘要显示问题
- 关于域名如何指向WordPress homepage问题的解决
- 解决移动端web页面整个背景图横向滚动问题
- HTML5和HLS协议两种技术完美结合解决移动端网页播放问题