<?php $content = $post->post_content;
$searchimages = '~<img [^>]* />~';
// Run preg_match_all to grab all the images and save the results in $pics
preg_match_all( $searchimages, $content, $pics );
// Check to see if we have at least 1 image
$iNumberOfPics = count($pics[0]);
if ( $iNumberOfPics > 0 ) {
// Your post have one or more images.
} else {
the_post_thumbnail();
}
?>