Just use following code the check for image in wordpress post.
Copy paste the following function in functions.php file.
function check_image(){
$content = $post->post_content;
$all_images = ‘~<img [^>]* />~’;
preg_match_all( $all_images, $content, $pics );
// Check to see if we have at least 1 image
$all_pics = count($pics[0]);
if ( $all_pics > 0 ) {
// Your post have one or more images.
return true
} else {
return false;
}
In post loop just add or call this function. This function will return the true or false.






I would like to say “wow” what a inspiring post. This is really great. Keep doing what you’re doing!!
I’ve just started off a blog, the knowledge you give on this site has aided me extremely. Thank you for all your time & work.
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.
Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader
Awesome post. I so good to see someone taking the time to share this information
This post makes a lot of sense !
Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader
Thanks for posting. Good to see that not everyone is using RSS feeds to build their blogs
Great read. Thanks for the info!
Intriguing post. I have been searching for some good resources for solar panels and discovered your blog. Planning to bookmark this one!
Thanks for posting. Good to see that not everyone is using RSS feeds to build their blogs
Hello, this is my first time i visit here. I found so many interesting in your blog especially on how to determine the topic. keep up the good work.
I’ve been checking your blog for a while now, seems like everyday I learn something new
Thanks
Nice post! You truly have a wonderful way of writing which I find captivating! I will definitely be bookmarking you and returning to your blog. In fact, your post reminded me about a strange thing that happened to me the other day. I’ll tell you about that later…