I am using timthumb as the image size management script throughout my wordpress site but I just noticed that an empty image tag shows up even when there is no thumbnail.
<?php if(has_post_thumbnail()):
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
?>
<div class="wp-caption alignright">
<img src="<?php bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $src[0]; ?>&w=145&h=80&q=100&zc=1" height="80" width="145" alt="<?php the_title(); ?>" class="wp-post-image" />
<p class="wp-caption-text"><?php the_post_thumbnail_caption(); ?></p>
</div>
<?php endif; ?>
I am doing it this way because I wanna show the caption whenever it exists. I also tried doing it all in php. I never do it like this, so I'm not sure if it's correct but It also shows the same thing and also echos the template_url before the image.
<?php if(has_post_thumbnail()){
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
echo '<div class="wp-caption alignright">
<img src="'. bloginfo('template_url') .'/scripts/timthumb.php?src='. $src[0] .'&w=145&h=80&q=100&zc=1" height="80" width="145" alt="'. the_title() .'" class="wp-post-image" />
<p class="wp-caption-text">'. the_post_thumbnail_caption() .'</p>
</div>';
} ?>
Am I doing something wrong here. That img tag is inside the condition right? Still a broken image place holder is showing up with every post. Image below

Can anyone tell me what's wrong with the code.
Thanks!
I appreciate all the help.
add_image_size('handler', 100, 50)to register your desired image sizes and set the same handler inwp_get_attachment_image_src($postId, 'handler')to display it. No need for timthumb here. – rofflox Aug 23 '11 at 11:23add_image_sizehas also crop-functionality. Set the last parameter totruewill force to crop the image. However, check the answer below. On my local install the thumbnail is only displayed if a featured image is set. – rofflox Aug 23 '11 at 12:43