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 am developing a child theme based on the twentyten theme and now i notice the featured image in the WP backend (wp-admin) shows the wrong scaled image.

It shows the "twenty ten" size, meaning an image scaled to x198.

How do i show the featured image of my chosen size???

regards,

share|improve this question
    
Where exactly do you want to use/see your custom image size output? Also: how/where did you define your custom image size(s)? –  Chip Bennett Mar 2 '12 at 22:01
    
@ChipBennett, i defined the custom sizes in my child theme's functions.php. The custom images work fine in my child theme, it is just the backend featured image, which is the one defined by Twenty Ten theme and not my child theme. I thought i overwritten it by adding this to my child theme's functions.php add_theme_support('post-thumbnails'); set_post_thumbnail_size(150, 150, false); –  alex Mar 2 '12 at 22:17
    
"the backend featured image" - WHERE EXACTLY are you seeing this featured image? Are you talking about the "Featured Image" meta box on the Edit Post screen, or somewhere else? –  Chip Bennett Mar 2 '12 at 22:26
    
sorry yes that's the one: the featured image in the meta box on the Edit Post screen. –  alex Mar 2 '12 at 22:35
add comment

2 Answers

up vote 1 down vote accepted

First: why do you care the size of the thumbnail displayed in the "Featured Image" meta box on the Edit Post screen?

Second: that image size isn't defined by Twenty Ten (or any other Theme). It's defined by core, and is actually simply calling the original image size, and scaling it.

Edit

Whoops; that was wrong. :) That Meta Box is apparently displaying the 'thumbnail' image size. (And I had forgotten that one of my primary beefs with Twenty Ten / Twenty Eleven is that they screw with the default thumbnail size.)

Start here:

<?php
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
?>

So, you were on the right track. :)

Next go to the define calls:

<?php
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) );
?>

So, the easiest way to override those defined sizes is via the twentyten_header_image_width and twentyten_header_image_height filters. e.g., in your Child Theme's functions.php file:

<?php
function wpse44268_filter_twentyten_header_image_width( $width ) {
    return '150';
}
add_filter( 'twentyten_header_image_width', 'wpse44268_filter_twentyten_header_image_width' );


function wpse44268_filter_twentyten_header_image_height( $height ) {
    return '150';
}
add_filter( 'twentyten_header_image_height', 'wpse44268_filter_twentyten_header_image_height' );
?>

These will define the post thumbnail as 150x150. Change the return values to suit your needs.

share|improve this answer
    
1/ the thumbnail displays a wrong part of the image 2/ i do think it's in Twenty Ten as 198px height isn't the original height and i see define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) ); and the thumbnail has this height. Also when i add a custom post type with post thumbnail support it will show the featured image dimensions i have defined for the custom post type. Really like to show the proper feature dimensions, so –  alex Mar 2 '12 at 23:38
    
See updated answer; while I'm still not sure why the cropping of the image in that meta box is a big deal, you're right that Twenty Ten is mucking with the thumbnail image size. –  Chip Bennett Mar 2 '12 at 23:53
    
Tx for the explanation, i am almost there. I have used your code suggestions, but i had to alter TwentyTen functions.php as well. Just this tiny bit set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true); to set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, false); I have tried to add set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, false); to my child functions.php, but it still crops the image like it is set to true. As i don't want to alter the parent theme i am wondering how i can make this work from child's functions.php –  alex Mar 3 '12 at 12:31
    
oh and another thing i notice. I have to delete the images and reupload the images to get the dimensions change to work. Which i don't understand as the same image formats are already in the uploads directory. –  alex Mar 3 '12 at 12:36
    
Just try regenerating your thumbnails. Use a Plugin like Regenerate Thumbnails or Ajax Thumbnail Rebuild. –  Chip Bennett Mar 3 '12 at 14:46
show 1 more comment

Changing the header image size to change the thumbnails size! You can do this without touching the parent theme file - in fact, any update will likely break your custom code. This is the point of child themes…

All you need to do is use add image size in your child theme:

 if ( function_exists( 'add_image_size' ) ) { 
    add_image_size( 'my-new-thumb', 150, 150,false );

And call this into the post_thumbnail in your template.

share|improve this answer
    
For one, the filters are applied from the child theme, so the parent one is not touched in the above answer. For another the OP was asking about the backend. Ain't no template used there... –  Johannes Pille Oct 26 '12 at 1:47
add comment

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.