Validate dimensions after cropping

I’d like to be able to validate the dimensions of an uploaded image but the validators seem to run during the initial upload which takes place before the Preview Step where cropping can be done. We have a set Crop ratio we want to use and it’s a likely scenario that after the cropping is done an image will meet the dimension requirements but not before. The docs state:

It is better to use validators instead of checking file properties in widget.onChange and widget.onUploadComplete callbacks. Validators are activated before a dialog gets closed thus improving your UX.

So is it possible to validate the after crop dimensions?


How do you want to validate the cropped image? I think you can achieve that with crop presets:

  • "disabled", crop is disabled. Can’t be combined with other presets.
  • "" or “free”, crop is enabled, and users can freely select any crop area on their images.
  • "2:3", any area with the aspect ratio of 2:3 can be selected for cropping.
  • "300x200" — same as above, but if the selected area is greater than 300x200 pixels, the resulting image will be downscaled to fit the dimensions.
  • "300x200 upscale" — same as above, but even if the selected are is smaller, the resulting image gets upscaled to fit the dimensions.
  • "300x200 minimum" — users won’t be able to define an area smaller than 300x200 pixels. If an image we apply our crop to is smaller than 300x200 pixels, it will be upscaled to fit the dimensions.

See this article to learn more:

If this doesn’t help, let me know.

Yep, I think one of these options should meet our needs. Thanks @Alex!