[wp-trac] [WordPress Trac] #36412: Custom Logo: Not able to "Skip Cropping" or crop non-square from small images.

WordPress Trac noreply at wordpress.org
Wed Apr 6 17:57:25 UTC 2016


#36412: Custom Logo: Not able to "Skip Cropping" or crop non-square from small
images.
-------------------------------------------------+-------------------------
 Reporter:  mikeschroder                         |       Owner:  obenland
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  4.5
Component:  Customize                            |     Version:  trunk
 Severity:  major                                |  Resolution:
 Keywords:  has-patch dev-feedback needs-        |     Focuses:  javascript
  testing                                        |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Yes, 36412.2.diff is looking a lot better. The complexity here comes from
 the fact that we do both cropping and scaling at the same time.

 There are still some assumption that are unclear. What are these two lines
 for? Why do they accept numeric values but turn them into boolean? How are
 themes supposed to use them?
 {{{
 flexWidth  = !! parseInt( control.params.flex_width, 10 ),
 flexHeight = !! parseInt( control.params.flex_height, 10 ),
 }}}

 These are inherited from the header image cropping, but seem to affect
 logos more.

 So what options a theme needs in order to define how an image is cropped
 and scaled for use as a logo? Logically there should be `width` and
 `height` or `min-width, max-width` and `min-height, max-height`.

 It sounds like `flexWidth` should replace `min-width, max-width` with
 something like "any width the user likes", but to do that it needs to be
 exclusive with (fixed) `width`. Same applies for setting height. So
 logically themes should be able to set `width` or `flex_width` but not
 both, and `height` or `flex_height` but not both. Then we end up with four
 user cases:

 1. Both `width` and `height` are set: we need to lock the aspect ratio and
 let the user select any part of the image.
 2. `width` and `flex_height` are set: user can select anything or skip
 cropping, we scale the image to the theme specified width after that.
 3. `flex_width` and `height` are set: user can select anything or skip
 cropping, we scale the image to the theme specified height after that.
 4. `flex_width` and `flex_height` are set: this is a tough one. The theme
 has decided to allow *any size* image for logo. We need to have some
 "sensible" default for that case, perhaps 100x100px or something.

 For all the above cases it also makes sense to have `min-width` and `min-
 height` values. These should probably be defaults but can be
 exposed/changeable by the themes.

 Another thing: as `width` is exclusive with `flex_width` and `height` is
 exclusive with `flex_height` we don't need all to be set. Logically if
 `width` is missing we should assume `flex_width`, etc.

 Also, the `x1, y1, x2, y2` settings for imgAreaSelect are for defining the
 initial coordinates of the crop box. They have no bearing on the actual
 crop the user would select. Should be used to place the crop rectangle in
 the middle and make it more visible? Having the crop area stretched to the
 image edges is probably not best?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36412#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list