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.
You might be able to do something like this with hideUploadButton
, the file-editor:complete
event, and info()
to notify what went wrong.
Alternatively, write a pre-processor which can fail and thus preventing going to the upload stage.
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]);