Yuvaleros / material-ui-dropzone

A Material-UI file upload dropzone
MIT License
485 stars 245 forks source link

Problem with cover image size restriction #279

Open Ved111 opened 3 years ago

Ved111 commented 3 years ago

Bug Report

Describe the bug

I tried adding the validator for cover image size using dropzoneProps, but it seems to be not working. There is no errors.

Steps to reproduce

<DropzoneArea acceptedFiles={["application/pdf", "application/epub"]} onChange = {onFilesChange.bind(this)} showFileNames dropzoneText="Upload Your Ebook here. Accepted formats: pdf/epub" filesLimit={1} showAlerts={true} dropzoneProps = { validator = (file) => { // You can access width/height properties if(file.width < '625px' || file.height < '1000px' || file.width > '10000px' || file.height > '10000' ) { return { code: "small-width", message:Image size not proper, } } return null } } />

kiocosta commented 6 months ago

Hey! I had the same issue. You probably don't need it anymore, but for anyone who might face this issue in the problem:

It turns out, material-ui-dropzone was using an outdated version of react-dropzone, which did not have the validator function. I have updated it and published in a new npm package here.

Add "@kiocosta/mui-file-dropzone": "4.0.3", to your package.json, run yarn again and the validator function should now be available inside dropzoneProps.