You should take a look at your Media Settings, to define the dimensions of your post thumbnails. Additionally, you could add this code to your functions.php
to specify your own thumbnails and dimensions:
// add thumbnail theme support
add_action('after_setup_theme','tjnz_theme_support');
function tjnz_theme_support() {
add_theme_support('post-thumbnails'); // wp thumbnails
set_post_thumbnail_size(170, 170, true); // default thumb size
add_theme_support('automatic-feed-links'); // rss thingy
}
// add thumbnail sizes
add_image_size( 'my-thumbnail', 320, 100, true );
add_image_size( 'my-other-thumbnail', 768, 400, true);
/* call with <?php the_post_thumbnail( 'my-thumbnail' ); ?> */
In your single.php
you can use the following code:
<?php
if ( has_post_thumbnail() ) :
the_post_thumbnail('my-thumbnail');
else :
?>
<img src="http://www.example.com/wp-content/uploads/No-Image-Available.png" alt="No artwork available for '<?php the_title(); ?>'" title="No artwork available for '<?php the_title(); ?>'" border="0" width="320" height="100" />
<?php endif; ?>
The else
part of the code makes sure that if no featured image is set, your post will still have an image. It will keep the format of your posts uniform.
For making sure that old images set to posts are also using your newly defined dimensions, you could use a plugin “Regenerate Thumbnails”. It will look into your functions.php
to get the dimensions, then looks at your wp-upload
folder and recreates all sizes for missing images for you.