Flexible heights for Twenty Eleven's custom headers. see #20448.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-04-15 19:53:10 +00:00
parent 9ef37a9427
commit 759f103994
2 changed files with 5 additions and 5 deletions

View File

@ -115,6 +115,8 @@ function twentyeleven_setup() {
// The height and width of our custom header.
'width' => apply_filters( 'twentyeleven_header_image_width', 1000 ),
'height' => apply_filters( 'twentyeleven_header_image_height', 288 ),
// Support flexible heights.
'flex-height' => true,
// Random image rotation by default.
'random-default' => true,
// Callback for styling the header.

View File

@ -79,21 +79,19 @@
// Check to see if the header image has been removed
$header_image = get_header_image();
if ( $header_image ) :
$header_image_width = get_theme_support( 'custom-header', 'width' );
$header_image_height = get_theme_support( 'custom-header', 'height' );
$header_image_width = get_custom_header()->width;
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
// The header image
// Check if this is a post or page, if it has a thumbnail, and if it's a big one
if ( is_singular() &&
has_post_thumbnail( $post->ID ) &&
if ( is_singular() && has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
$image[1] >= $header_image_width ) :
// Houston, we have a new header image!
echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
else : ?>
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
<?php endif; // end check for featured image or standard header ?>
</a>
<?php endif; // end check for removed header image ?>