I found this script for wordpress, to get the image of the post and add it to the wordpress theme.
See the script:
function catch_that_image() {
global $post, $posts;
$first_img = '';
$new_img_tag = "";
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post- >post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image with 0 width
$new_img_tag = "<img src='/images/noimage.jpg' width='0px' class='alignleft' />";
}
else{
$new_img_tag = "<img src='" . $first_img . "' width='100px' height='100px' class='alignleft' />";
}
return $new_img_tag;
}
end of script
This little code we added to draw the image somewhere in the theme.
<?php echo catch_that_image() ?>
As you can see the script leaves the image scaled at 100x100, I would like to control the size of the image by this code:
<?php echo catch_that_image() ?>
I need to leave the image on each page with different dimensions.