php - How to get the WordPress post thumbnail (featured image) URL?
767
I am using this function to get the featured images:
<a href="#" rel="prettyPhoto">
<?php the_post_thumbnail('thumbnail'); ?>
</a>
Now I want to get the full featured image on click on the anchor tag for which I need a featured image URL in
<a href="here" rel="prettyPhoto">
How can I fix this?
Answer
Solution:
Check the code below and let me know if it works for you.
Answer
Solution:
If you want JUST the source, and not an array with other information:
Answer
Solution:
Answer
Solution:
Easy way!
Answer
Solution:
This perfectly worked for me:
Answer
Solution:
I think this is the easiest solution and the updated one:
Answer
Solution:
This is the simplest answer:
Answer
Solution:
You can try this:
Answer
Solution:
Try this one
Answer
Solution:
I had searched a lot and found nothing, until I got this:
<?php echo get_the_post_thumbnail_url( null, 'full' ); ?>
Which simply give you the full image URL without the entire
<img>
tag.Hope that can help you.
Answer
Solution:
You can try this.
Answer
Solution:
You can also get it from post_meta like this:
Answer
Solution:
You can also get the URL for image attachments as follows. It works fine.
Answer
Solution:
You will try this
Answer
Solution:
Answer
Solution:
If the post is an image and we already know what the image is, it's possible to get the thumbnail URL without too much hassle:
Answer
Solution:
Simply inside the loop write
<?php the_post_thumbnail_url(); ?>
as shown below:-Answer
Solution:
Use:
You can change the
thumbnail_size
value as per your required size.Answer
Solution:
You can also get the URL for image attachments as follows:
Answer
Solution:
You can get image src for specific size by
wp_get_attachment_url
function.Answer
Solution:
if you want to fetch full image size from post thumbnail you can use this code.
here, get_the_ID() is post id.
Answer
Solution: