How do I set the default “feature image” size?

I know I can set up post, pages, and custom post types to use featured images in wordpress by enabling theme support:

add_theme_support( 'post-thumbnails');

Or enabling theme support for a specific set of post types:

    add_theme_support( 'post-thumbnails', array('post','page'));

I also know that I can add an “image size” like this:

add_image_size( 'media_library', 333, 230, true );

But how do you control which image size of the “feature image” actually displays on the edit screen of WordPress? For example in TwentyEleven I have uploaded a square photo and it shows up as a rectangle in the featured image box on the edit screen:

Picture 1.png

How do you pick which image size shows up there?

Solutions Collecting From Web of "How do I set the default “feature image” size?"

I believe that is what the set_post_thumbnail_size function is for.

Set the default Post Thumbnail dimensions. To register additional image sizes for Post Thumbnails use: add_image_size().


If you added a custom with the 3 sizes:

add_image_size( 'small', 111, 222, true );
add_image_size( 'medium', 333, 333, true );
add_image_size( 'large', 444, 555, true );

You would then use them in the theme files using the names you gave for the function like this:

<?php the_post_thumbnail('small'); ?>


<?php the_post_thumbnail('medium'); ?>


<?php the_post_thumbnail('large'); ?>

Existing images would need to be regenerated by using the regenerate post thumbnails plugins, but all new ones would get cropped as specified.

Doing a search for Featured Image I was lead to \wp-admin\edit-form-advanced.php, where I found a metabox being added with a callback param of post_thumbnail_meta_box.

I then did a search for post_thumbnail_meta_box, and ended up in \wp-admin\includes\meta-boxes.php, where we can see that WP gets the post thumbnail with:

$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );

and then does some magic on it with this:

echo _wp_post_thumbnail_html( $thumbnail_id );

Searching for function _wp_post_thumbnail_html leads us to \wp-admin\includes\post.php, where we see that WP determines the size it wants to use, but then at the very last instant, we are given the opportunity to mess with the image via:

return apply_filters( 'admin_post_thumbnail_html', $content );


function admin_post_thumbnail_kittenifier( $content ) {
    // In reality, you might want to replicate some of the code from _wp_post_thumbnail_html(), but this gives you the idea
    return "<img src='' alt='I can has toxoplasma gondii?'/>";
add_filter( 'admin_post_thumbnail_html', 'admin_post_thumbnail_kittenifier' );