A common problem I’ve run into while making templates is using TimThumb.php with the WordPress Featured Image to resize on the fly. Google seems to lead to very few solutions for some reason so I wanted to share my way of solving this problem.
Here’s a little snippet of code that I use in my themes to accomplish getting the Featured Image and resizing it.
<?php if (has_post_thumbnail( $post->ID )): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?> <img src="<?php echo _PLUGINORTHEMEURL; ?>/scripts/timthumb.php?src=<?php echo $image; ?>&w=IMAGEWIDTH&h=IMAGEHEIGHT&zc=1" /> <?php endif; ?>
Just remake sure the have the correct plugin or theme url and set the image height and width. I hope this helps anyone else that was having the same problems as me. Leave any questions if you have them.