function catch_that_image_thumbnail($neirong) {
// global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[/'"]([^/'"]+)[/'"].*>/i', $neirong, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$site_url = bloginfo('template_url');
$first_img = "$site_url/images/no-thumb.jpg";
}
return $first_img;
}
用法:$imgs = catch_that_image_thumbnail($post->post_content);