Add Additional Image Sizes

You can add an image size to your WordPress site by using the following function: Place the above code in your functions.php file to use in your theme.

The image size won’t show up in your media settings, or your post edit screen, but it will be usable when calling a post thumbnail via PHP, like so:

<?php echo get_the_post_thumbnail($post->ID, 'product-thumb'); ?>

Code Snippet:

if ( function_exists( 'add_image_size' ) ) {
	add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
	add_image_size( 'homepage-thumb', 220, 180, true ); //(cropped)
} ?>

Posted in Images