Force crop before upload

Started by zasuh3 replies617 views
zasuhOriginal post
#1

Is there a way to know if the image has been cropped before uploading it? Trying to disable the upload button if a user doesn’t crop it first.

MerlijnTransloadit team
#3

Alternatively, write a pre-processor which can fail and thus preventing going to the upload stage.

#4

Tried to do something like this but had no luck:

const [isCropped, setIsCropped] = useState(false);

useEffect(() => {
    uppy.on('file-editor:complete', (file) => {
      setIsCropped(true);
      const img = URL.createObjectURL(file.data);
      setImage(img);
    });
    uppy.on('file-removed', () => setImage(''));
    uppy.on('upload', () => {
      if (!isCropped) {
        console.log('Not cropped');
        return;
      }
      console.log('Cropped');
    });
  }, [uppy]);