Add custom thumbnail sizes to your WordPress theme

To add custom thumbnail sizes to your theme, add this to your theme’s functions.php:

/*  Image thumbnail sizes
/* ------------------------------------ */
function alx_setup()
{
	add_image_size( 'thumb-small', 200, 200, true ); // Hard crop to exact dimensions (crops sides or top and bottom)
	add_image_size( 'thumb-medium', 520, 9999 ); // Crop to 520px width, unlimited height
	add_image_size( 'thumb-large', 720, 340 ); // Soft proprtional crop to max 720px width, max 340px height
}
add_action( 'after_setup_theme', 'alx_setup' );

To display a featured image with your new size (in this case “thumb-small”) in a post, just add:

<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumb-small' ); } ?>

Read more