The Short Answer…
In path-to-your-blog-install/wp-content/themes/twentyten/header.php on line 79, replace this:
<img src="<?php header_image(); ?>" alt="" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" />
With this:
<?php if(strlen(get_header_image()) > 0) : ?>
<img src="<?php header_image(); ?>" alt="" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" />
<?php endif; ?>
The Long Answer…
I was recently working with the twentyten template that comes pre-installed with WordPress. This template is nice enough to include a quite a few header images. In the Admin section, under Appearance > Header, they also include an option to Remove Header Image.
The problem here is, when you do remove the header image via the Admin page, your blog still tries to display an image, and you end up with a blank space at the top of your page with a broken image displayed. So, I set out to correct this problem.
The solution I found was in the header.php file located in the directory path-to-your-blog-install/wp-content/themes/twentyten on line 79.
The original file looks like this:
<img src="<?php header_image(); ?>" alt="" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" />
What happens here is header_image() is echoing the result from get_header_image(), both defined in wp-includes/theme.php. When there is no header image, it returns a blank value and your image tag ends up looking like this:
<img src="" alt="" width="" height="" />
And that’s why you get a blank image.
To correct this, I replaced the code on line 79 with the following:
<?php if(strlen(get_header_image()) > 0) : ?>
<img src="<?php header_image(); ?>" alt="" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" />
<?php endif; ?>
Viola! When the length of the image name returned from get_header_image() is greater than zero, that is when there is an image specified, the image tag is passed to the browser. Otherwise, that is when there is no image specified, no image tag is displayed.
why not:)