The following snippet of code will check to see if your post or custom post type has any attachments and then allows you to use an if else statement. You can change the number of attachments to check for, so if you wanted to check if there is more than […]
The following snippet will give you just the url for the featured image without wrapping it in any tags.
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail-size', true);
Code credit to: http://www.wpbeginner.com/wp-themes/how-to-get-the-post-thumbnail-url-in-wordpress/