Ok guys.. I got it finally working with my below code.
function wpse55748_filter_post_thumbnail_html( $html ) {
// If there is no post thumbnail,
// Return a default image
global $post;
$pID = $post->ID;
$thumb = 'large';
$imgsrc = FALSE;
if (has_post_thumbnail()) {
$imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($pID),$thumb);
$imgsrc = $imgsrc[0];
} elseif ($postimages = get_children("post_parent=$pID&post_type=attachment&post_mime_type=image&numberposts=0")) {
foreach($postimages as $postimage) {
$imgsrc = wp_get_attachment_image_src($postimage->ID, $thumb);
$imgsrc = $imgsrc[0];
}
} elseif (preg_match('/<img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
$imgsrc = $match[1];
}
if($imgsrc) {
$imgsrc="https://wordpress.stackexchange.com/questions/283546/<img src="".$imgsrc.'" alt="'.get_the_title().'" class="summary-image" />';
$html = $imgsrc;
}
if ( '' == $html ) {
return "https://wordpress.stackexchange.com/questions/283546/<img src="' . get_template_directory_uri() . '/images/default-featured-image.png" />';
}
// Else, return the post thumbnail
return $html;
}
add_filter( 'post_thumbnail_html', 'wpse55748_filter_post_thumbnail_html' );
Here I first search the post content with regex if the content have any kind if