Featured image always rendered with 198px of height?

I added the following to my functions.php file:

set_post_thumbnail_size( 500, 500);

I enabled featured image (support => 'thumbnail') in a custom post type a created (called Page Content).

Read More

When I set an image as featured image (the image I’m using has 500px of height) , the image is always rendered with 198px of height.

EDIT:

It renders 198px in final page and 117px in the admin panel.

This is the code of the final output:

<img class="attachment-post-thumbnail wp-post-image" width="448" height="198" title="2974999772_7085da4d34" alt="2974999772_7085da4d34" src="http://localhost/wp-alex-chen/wp-content/uploads/2011/01/2974999772_7085da4d344-448x198.jpg

This is the code of the featured image in the admin panel:

<img width="266" height="117" title="2974999772_7085da4d34" alt="2974999772_7085da4d34" class="attachment-post-thumbnail" src="http://localhost/wp-alex-chen/wp-content/uploads/2011/01/2974999772_7085da4d344-448x198.jpg">

Edit Post panel:

enter image description here

Any suggestions to solve this? (the ‘normal’ Posts have also the same problem (height= 198px)

EDIT2: I aded this to functions.php:

if ( function_exists( 'add_image_size' ) ) add_theme_support( 'post-thumbnails' );
if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 'thumb-1', 320, 280, true );
}

It is set to have hard-crop but the image is rendered as 250px 280px (it should render as 320px x 280px).

Related posts

Leave a Reply

3 comments

  1. I think you are using a child theme of TwentyTen and in TwentyTen theme you have this line:

    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    

    and HEADER_IMAGE_HEIGHT is 198px.

  2. Using <?php the_post_thumbnail('large'); ?> instead of <?php the_post_thumbnail(); ?> fixed the problem.

    <?php the_post_thumbnail(); ?> seems to have a very weird default setting for resizing thumbnails.

  3. Okay, after inspecting a little bit how wordpress is generating the html for the featured image I found with editor_max_image_size in wp-includes/media.php on line 76 the decisive filter to hook in.

    At first, of course, you have to setup your individual image size as usual in your function.php, for example i want a post-thumbnail size 600px x 400px:

    function abc_set_size() {
       add_image_size( 'post-thumbnail', 600, 400, true );
    }
    add_action( 'after_setup_theme', 'abc_set_size' );
    

    WordPress wants to use this dimension for the featured image (which was setup in the theme) inside the backend but rollback to a standard size with this filter in line 76. The filter hook has 3 parameters to differentiate which image should be ‘tuned’ in his dimension:

    function abc_my_editor_size($size_array,$size,$context) {
       global $_wp_additional_image_sizes;
    
       if($size == 'post-thumbnail' && $context == 'edit')
           return array( 
              $_wp_additional_image_sizes[$size]['width'],    
              $_wp_additional_image_sizes[$size]['height'] );
    
       return $size_array;
    }
    add_filter('editor_max_image_size', 'abc_my_editor_size', 10, 3);
    

    Just like wanted, only the image dimension for the featured image inside the admin backend is edited. I use the global array $_wp_additional_image_sizes to have access to the my setted image dimension for a post-thumbnail.

    Works fine for me, i would recommenend it ! Any thoughts about this ?