How to remove the header image in Twenty Ten 1.1 wordpress theme

I tried to remove header image in Twenty Ten 1.1 wordpress theme by clicking Remove Header Image button in header administration. Image removed but a blank space left. It’s funny. Okay let’s go into the file header.php and see what is there. There is code that shows header image:

<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

Everything is good but there is no checking whether there is a image or not. So I just add it to code, change with new code and now it like this:

<?php if(get_header_image()){ ?>
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
<?php } ?>

Now if I delete header image then header image will not be shown like I wanted.

Fix for image attachment problems in Twenty Ten 1.1 wordpress theme

I noticed after uploading any image 900 pixels width and viewing the picture on the attachment page, then this image was cropped and was always 198 pixels in height. It was strange, then I find out what was going on in the theme code. I found in the file attachment.php code which is responsible for displaying an image for attachment page:

$attachment_size = apply_filters( 'twentyten_attachment_size', 900 );
echo wp_get_attachment_image( $post->ID, array( $attachment_size, 9999 ) ); // filterable image width with, essentially, no limit for image height.

This code show 900 pixels width images, but 900 pixels width image can be the original image or image for a header (or featured), and therefore code will use the picture for the header. Twenty Ten 1.1 theme adds new image size 940×198 pixels, but sometimes image not big enough so it cut to 900×198, 800×198 etc. That is why those images are displayed.

To solve this problem, I replaced 2 lines code to new:

echo wp_get_attachment_image( $post->ID, 'large' );

Now attachment page always display large image, if there is no large image (too small to crop) then it will display original image.

Then specifically for Twenty Ten 1.1 theme  I changed media settings in administration. Thumbnail size is good 150×150 so I don’t change it, theme use thumbnail in galleries. Medium size I changed to 640 max width and 9999 max height, because Twenty Ten 1.1 theme post max width 640 so this image size perfect for inserting images in posts. Next large size I changed to max width 900 and 9999 max height, because this image will be in attachment page.