[wp-trac] [WordPress Trac] #17242: Themes: Allow flexible sizes for custom header uploads
WordPress Trac
wp-trac at lists.automattic.com
Thu May 5 10:38:34 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: has-patch dev-feedback |
------------------------------------+------------------
Changes (by lancewillett):
* keywords: needs-patch 2nd-opinion => has-patch dev-feedback
Comment:
I've been working on this for a few days now, changing the crop parameters
and seeing how things work when you change only the width or height when
you crop an uploaded image.
I also experimented with replacing HEADER_IMAGE_WIDTH and
HEADER_IMAGE_HEIGHT in a few places.
Attached is a patch with my first pass, it's mostly a proof-of-concept for
the cropping mechanism changes.
There are a to main blocker issues with this feature:
1. Image dimensions are not available if not the default size.
* Themes with flexible uploaded images have no mechanism to get the
width/height dimensions of the uploaded image, for use in HTML attributes
or CSS.
* Themes that use the same values stored in HEADER_IMAGE_WIDTH and
HEADER_IMAGE_HEIGHT definitions in other places than the custom header are
going to have trouble if they allow flexible sizes. For example, if upload
a smaller header than is defined in the theme — there isn't a way for the
theme to get its dimensions and apply it to other areas in the theme.
* In Twenty Eleven you could end up with a short header image (works
great) but taller featured image headers since the featured image call
doesn't change to the smaller dimension.
2. Cropping tool isn't ready for flexibility.
* To allow correct cropping by one dimension only (when the width or
height isn't flexible) the existing crop functionality would need a
rewrite to remove the need for an exact aspect ratio.
* I found that when one dimension is flexible (and the other not) the
cropping tool "zooms up" to the uploaded image dimension that you've fixed
as not flexible. So even if you crop correctly the fixed dimension
changes.
* Allowing the 'flexible_header_image_upload' call with ints as arguments
proved a bit too complex. My patch implements the arguments as boolean
values, so the flexibility is either on or off. The maximum width or
height is then taken from HEADER_IMAGE_WIDTH and HEADER_IMAGE_HEIGHT.
All in all I think this idea is still worth pursuing, but it seems that
we'd need to first revamp all the cases where HEADER_IMAGE_WIDTH and
HEADER_IMAGE_HEIGHT are used, and replace them with set and get functions.
Set to denote the defaults (and any flexibility desired) and get to make
sure you can return image info anywhere in the theme — not only the source
path (as {{{get_header_image()}}} does now) but also other image
attributes.
If the flexible height is a blocker for Twenty Eleven we should consider
implementing it in the theme itself — using user input to set the height
value — and use that dimension to override HEADER_IMAGE_HEIGHT in the
theme.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17242#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list