[wp-trac] [WordPress Trac] #36316: Image editor: improve form validation errors handling

WordPress Trac noreply at wordpress.org
Wed Mar 23 23:33:39 UTC 2016

#36316: Image editor: improve form validation errors handling
 Reporter:  afercia         |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  ui, javascript  |
 When editing images and entering values for Scale, Crop ratio/selection in
 the Image Editor form, the check for entered values could be improved a
 bit. I've noticed this because a plugin was giving a JavaScript error and
 as a consequence, when entering new scale width and height, in the input
 field a "NaN" (literally) value appeared :)
 Even with no plugin activated and no JS errors, when entering non-numbers,
 "Nan" is displayed to users, see below:


 Users would probably be a bit confused by seeing "NaN", I'd say it could
 be improved a bit. Worth noting the same thing doesn't happen in the Crop
 input fields: when entering non-number values, the field gets emptied.

 Not pretending to completely refactor the code behind the Image Editor,
 which is a bit old but still works. I'd propose to keep things simple and:

 - use the same check for a numeric value used on the Crop fields on all
 the other fields: don't display "NaN", just empty the field
 - remove the inline script that runs the initialisation of the Image
 Editor and call it after the Editor UI is fully ready; this would probably
 help a bit to mitigate lack of data necessary for a correct initialisation
 (technical detail: the plugin JS error caused the `imageEdit.hold` object
 to be empty because not initialised)

Ticket URL: <https://core.trac.wordpress.org/ticket/36316>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list