Possible Duplicate:
Retrieve 1st image in post and set it as featured image, when post is saved/updated
VT-resize image and display it
好了,伙计们,我修改了这个脚本,以便在显示之前裁剪图像。
// Get URL of first image in a post
function catch_that_image() {
global $post, $posts;
$first_img = \'\';
ob_start();
ob_end_clean();
$output = preg_match_all(\'/<img.+src=[\\\'"]([^\\\'"]+)[\\\'"].*>/i\', $post->post_content, $matches);
$first_img = $matches [1] [0];
// no image found display default image instead
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
$first_img = vt_resize( $first_img, \'\', 608, 250, true );
return $first_img;
}
这是我用来显示它的代码:<img src="<?php echo catch_that_image() ?>" width="608" height="250" />
vt\\U resize功能已内置于主题中。然而,代码并没有返回url,它只是返回一个数组。我做错了什么?我希望一个好人能回答我的问题,谢谢=)