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:

Code Snippet:

<?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)
} ?>

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!