The following snippet below will let you add custom images sizes to WordPress.
1 2 3 4 5 6 7 8 9 10 | // Add Feature Image size, hard crop if ( function_exists( 'add_image_size' ) ) { add_image_size( 'feature-image', 570, 285, true ); add_image_size( 'feature-image-small', 285, 285, true); add_image_size( 'feature-image-home', 285, 303, true); } // To use the image, if feature image exist <?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'feature-image' ); } ?> // Add a class to the image <?php echo the_post_thumbnail( 'feature-image-large', array('class' => 'feature-image') ); ?> |
Snippet Source/Credit: Snipplr