Possible Duplicate:
Retrieve 1st image in post and set it as featured image, when post is saved/updated
VT-resize image and display it
ok guys, I have this script which I modified in order to crop the image before being displayed.
// 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;
}
this is the code I use to display it:
<img src="<?php echo catch_that_image() ?>" width="608" height="250" />
The vt_resize function is already built in within the theme. However the code is not returning the url, it just return an array. What am I doing wrong?
I hope a nice person answers to my question, thank you =)