有时写WEB程序时本文主要介绍WordPress模板开发,需要调用优酷视频的图片缩略图,本文向大家分享一下如何自动调用优酷视频图片缩略图。 完整的调用函数,请把这段函数添加到functions.php文件中: function get_youku_thumb($url) { $content = file_get_contents($url); preg_match( ‘/id=”s_msn2″.*?screenshot=(.*?)”.?target=/’, $content, $matchs ); return $matchs[1]; } echo get_youku_thumb(‘http://v.youku.com/v_sho […]
标签:缩略图
两招提取WordPress文章缩略图
针对WordPress文章缩略图的提取教程,网上已经有很多,办法是很多的,本文只向大家推荐两招,希望对大家有用。 方法一:直接用函数抓取日志内容里的第一个图片。 在主题函数文件functions.php里添加代码: function catch_that_image() { global $post, $posts; $first_img = ”; ob_start(); ob_end_clean(); $output = preg_match_all(‘/ /i’, $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img […]
巧用timthumb.php为WordPress博客添加缩略图
WordPress自带着缩略图功能,但这个默认功能实在不怎么好用,timthumb.php 是一个由Google开发的插件,我们完全可以直接不用WordPress的默认缩略图功能,也不用使用任何第三方插件,仅此一个文件即可实现缩略图功能。 首先把timthumb.php文件下载到你的主题目录或其他目录; 在你想显示缩略图的位置贴上以下代码: