Try it with this (inside the loop):
$post_thumbnail_id = get_post_thumbnail_id();
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
Thanks.. its working.. but i want to get the thumbnail from specific size as i defined the size of the thumbnails:
add_image_size('blog', 190, 140, true);
add_image_size('news', 150, 100, true);
add_image_size('page', 650, 270, true);
I believe this is how I do it…
<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'large', true);
echo $image_url[0]; ?>
where ‘large’ is my thumbnail…..
Cool.. its working. Another issue that is bugging me last couple of days is that.
Suppose as my previous code example i have three image sizes. one that i will add in page featured image which i will not use for blog post and news section.
But when i upload any featured image wordpress will automatically make three new images using those sizes. right? So this can be waste of space in a long run. Is there any way i can prevent this.
Let me know if anything unclear. Thanks again for your help. Greatly appreciated!
I don’t know that there is any way to block generation of the image sizes based on context…..
If storage is a concern, you could just pre make your images, and use custom fields to attach or something.
But that isn’t all that convenient really…..
Just checking if there is any way to do that.. like to keep things tight 🙂 but i guess the storage is not really a concern…