Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#17242 closed task (blessed)

Themes: Allow users to set the height for custom header image — at Initial Version

Reported by: lancewillett Owned by:
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch commit
Focuses: Cc:


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' );

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' );

Change History (1)

Note: See TracTickets for help on using tickets.