Unless there’s some part of your problem I don’t grasp, what’s wrong with a simple mash-up of the two given snippets?
<?php
global $post;
$urlbox = get_url_desc_box();
$post_thumb = get_the_post_thumbnail( $post->ID, 'screenshot' );
if( !empty( $urlbox[0] ) && !empty( $post_thumb ) ) {
echo sprintf( '<a target="_blank" href="https://wordpress.stackexchange.com/questions/66759/%1$s">%2$s</a>', $urlbox[0], $post_thumb );
}
?>
Edited: get_the_post_thumbnail
vs. the_post_thumbnail
In accordance to the general WP function naming convention, the_post_thumbnail
echoes/displays the image, whereas get_the_post_thumbnail
returns it.
In addition to that, the_post_thumbnail
can only be used inside the Loop, while get_the_post_thumbnail
takes one further parameter, the post ID. The two optional paramters after the ID are identical to those of the_post_thumbnail
.
Hence, you can use get_the_post_thumbnail( $post->ID, 'screenshot' )
to preserve your size settings.