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:

Read More
    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 http://img72.imageshack.us/img72/1325/picture1fj.png

How do you pick which image size shows up there?

Related posts

Leave a Reply

3 comments

  1. 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'); ?>
    

    or

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

    and:

    <?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.

  2. Doing a search for Featured Image I was lead to wp-adminedit-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-adminincludesmeta-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-adminincludespost.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 );
    

    Example:

    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='http://placekitten.com/200/300' alt='I can has toxoplasma gondii?'/>";
    }
    add_filter( 'admin_post_thumbnail_html', 'admin_post_thumbnail_kittenifier' );