[wp-trac] [WordPress Trac] #17242: Themes: Allow flexible sizes for custom header uploads
WordPress Trac
wp-trac at lists.automattic.com
Tue Jan 31 20:27:04 UTC 2012
#17242: Themes: Allow flexible sizes for custom header uploads
----------------------------+------------------
Reporter: lancewillett | Owner:
Type: task (blessed) | Status: new
Priority: normal | Milestone: 3.4
Component: Themes | Version:
Severity: normal | Resolution:
Keywords: dev-feedback |
----------------------------+------------------
Comment (by aaroncampbell):
If you want to test with your own theme, here's how you add support for
flex headers:
{{{
// Add support for flexible headers
$header_args = array(
'random-default' => true,
'flex-height' => true,
'suggested-height' => 200,
'flex-width' => true,
'suggested-width' => 950,
);
add_theme_support( 'custom-header', $header_args );
}}}
Then when registering default headers you want to specify a width and
height:
{{{
register_default_headers( array (
'berries' => array (
'url' => '%s/images/headers/berries.jpg',
'thumbnail_url' => '%s/images/headers/berries-
thumbnail.jpg',
'description' => __( 'Berries', 'essence' ),
'width' => 940,
'height' => 198,
),
) );
}}}
To display the header you can do something like this:
{{{
<div id="headimg" style="background-image:url(<?php esc_url (
header_image() ) ?>);width:<?php echo get_header_image_width();
?>px;height:<?php echo get_header_image_height(); ?>px;"></div>
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17242#comment:48>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list