[wp-trac] [WordPress Trac] #17242: Themes: Allow flexible sizes for custom header uploads (was: Themes: Allow any size custom header image)

WordPress Trac wp-trac at lists.automattic.com
Wed Apr 27 20:46:24 UTC 2011


#17242: Themes: Allow flexible sizes for custom header uploads
-------------------------------------+------------------
 Reporter:  lancewillett             |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  3.2
Component:  Themes                   |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch 2nd-opinion  |
-------------------------------------+------------------
Description changed by lancewillett:

Old description:

> When uploading a custom header image allow users to specify the desired
> height of the image.
>
> '''Admin UI'''
>
> Appearance > Header could show the height as a text input field with the
> default height as the value. After you upload an image the cropper tool
> would use the value you entered for the height.
>
> The value would fall back to height value defined in
> {{{HEADER_IMAGE_HEIGHT}}} in the theme functions.php file if not changed
> by the user. See attached screenshot for example of the editable height.
>
> '''Theme Support'''
>
> To set a default value but allow overriding it from Appearance > Header
> use:
> {{{
>         define( 'HEADER_IMAGE_HEIGHT', '200' );
>         define( 'ALLOW_CUSTOM_HEADER_IMAGE_HEIGHT', true );
> }}}
> Default value for {{{ALLOW_CUSTOM_HEADER_IMAGE_HEIGHT}}} is false.
>
> To use the header image in template files use {{{HEADER_IMAGE_HEIGHT}}}
> value in HTML attributes or use dynamic CSS to use the header image as a
> background image and set the height of its container to
> {{{HEADER_IMAGE_HEIGHT}}}.
>
> Note: If using this feature themes should avoid having a hard-coded
> height for the header image in the styles used for layout.
>
> '''Crop Without Height'''
>
> A tangential idea: Allow a header image to be uploaded constrained by
> width but not height in the crop tool. After upload use the image height
> as the custom height value for the theme.
>
> In this case, in functions.php theme authors could set the height
> definition to "custom" default value and when calling
> {{{HEADER_IMAGE_HEIGHT}}} in templates it'd return the height of the
> uploaded image.
> {{{
>         define( 'HEADER_IMAGE_HEIGHT', 'custom' );
>         define( 'ALLOW_CUSTOM_HEADER_IMAGE_HEIGHT', true );
> }}}

New description:

 If a theme allows flexible header images the custom header feature should
 adjust the crop settings on upload to let the image through.

 '''Theme Support'''

 {{{add_theme_support( 'allow_flexible_header_height', 200 );}}} [[BR]]
 Where 200 is the maximum height allowed.

 {{{add_theme_support( 'allow_flexible_header_width', 1000 );}}} [[BR]]
 Where 1000 is the maximum width allowed.

 '''Custom Header Code'''

 If the theme_support option exists and passes second argument (dimension
 as an integer), and the uploaded image dimension is higher, crop to size.
 If the uploaded image dimension is lower, save it with no crop.

 If the option is on but dimension value is false or 0, let any size
 through (no crop at all).

 '''Admin UI'''

 If a theme supports this, list the maximum dimensions in Appearance >
 Header. If no maximums are defined, leave it blank.

--

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17242#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list