Hi there.
Thank you so much. I manage to find the correct script. I would like to share here.
I have added the below code in functions.php
//Show the first image associated with the post
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='alignright' />";
}
else{
$new_img_tag = "<img src='" . $first_img . "' width='600px' ' height='300px' class='alignright' />";
}
return $new_img_tag;
}
// Ditto Posts Thumbnail Output
add_filter( 'mtphr_dnt_posts_thumb', 'custom_dnt_posts_thumb', 10, 3 );
function custom_dnt_posts_thumb( $image, $id, $meta_data ) {
return catch_that_image();
}
Have a good day.