<?php
//添加特色缩略图支持
if ( function_exists('add_theme_support') )add_theme_support('post-thumbnails');
//输出缩略图地址
function the4_thumb(){
global $post;
if( $values = get_post_custom_values("thumb") ) {	//输出自定义域图片地址
$values = get_post_custom_values("thumb");
$post_thumbnail_src = $values [0];
} elseif( has_post_thumbnail() ){    //如果有特色缩略图，则输出缩略图地址
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'full');
$post_thumbnail_src = $thumbnail_src [0];
} else {
$post_thumbnail_src = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
if(!empty($matches[1][0])){
$post_thumbnail_src = $matches[1][0];   //获取该图片 src
}else{	//如果日志中没有图片，则显示随机图片
$random = mt_rand(1, 9);
$post_thumbnail_src = get_template_directory_uri().'/dist/assets/images/1.png';
//如果日志中没有图片，则显示默认图片
//$post_thumbnail_src = get_template_directory_uri().'/images/default_thumb.jpg';
}
};
echo $post_thumbnail_src;
}