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 http://img72.imageshack.us/img72/1325/picture1fj.png
How do you pick which image size shows up there?
I believe that is what the
set_post_thumbnail_size
function is for.See http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size
If you added a custom with the 3 sizes:
You would then use them in the theme files using the names you gave for the function like this:
or
and:
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 towp-adminedit-form-advanced.php
, where I found a metabox being added with a callback param ofpost_thumbnail_meta_box
.I then did a search for
post_thumbnail_meta_box
, and ended up inwp-adminincludesmeta-boxes.php
, where we can see that WP gets the post thumbnail with:and then does some magic on it with this:
Searching for
function _wp_post_thumbnail_html
leads us towp-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:Example: