Get featured image thumbnail as image or URL

the following code will return a featured image with <img> tags in a medium size.


the following code will give you the URL of the featured image thumbnail (small) only.

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

if you want to get the medium size thumbnail using the same code use:

$url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'medium');

If you like to identify if the featured image exist:

<?php if ( has_post_thumbnail()){ //do something } ?>