I am using the following code to display the thumbnail image named th-mag2 :
<img src="<?php echo the_post_thumbnail('th-mag2'); ?>" width="100%" class="object-fit card-img-top" height="150px" alt="img-news" loading="lazy">
But when it is displayed on the site, it is displayed as follows:
Please help me ….
thanks
2
Answers
I am not an expert but the issue looks familiar to me. So I am trying to help you.
You can try this one with
.jpeg
as well instead of.jpg
if that’s your image extension.You can also try this one if the first one doesn’t work (with the correct image extension):
if you want the Post Thumbnail URL only then you can not use the_post_thumbnail() function, it will print the complete Image Structure with Image tag also,
So what you actually need to do is