Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

share|improve this question
    
@janoChen - Where is it always rendered 428px x 198px? What does the code look like that renders it? (Details are your friend.) –  MikeSchinkel Jan 31 '11 at 11:49
    
@MikeSchinkel I added that in the EDIT. –  janoChen Jan 31 '11 at 11:56
    
@jano: Please post that images original pixel size and aspect ratio. Then compare that with your thumbnail images aspect ratio. IIRC wordpress will always use the smallest size of any side not to cut stuff away. –  hakre Jan 31 '11 at 12:40
    
@janoChen - Not sure I know how to fix this without seeing your system. Maybe someone else can solve it. –  MikeSchinkel Jan 31 '11 at 12:46
    
@hakre the original picture is 280px x 320px, for some reason Wordpress is now making it 280px x 280px. Even if I'm using this: add_image_size( 'thumb-1', 320, 280, true ); –  janoChen Jan 31 '11 at 12:48

3 Answers 3

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.

share|improve this answer
2  
the_post_thumbnail() in Codex has note about crop not working somehow with it. I am not sure about specifics but I think that is likely what caused your issues. –  Rarst Jan 31 '11 at 13:19
    
@Rarst: I'm smelling the same, I wish Jan could add two cents, he probably knows best. –  hakre Jan 31 '11 at 13:29

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.

share|improve this answer
    
commenting out this code fixed this issue for me thanks –  Xavier Oct 6 '11 at 13:15

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 ?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.