Skip to content

Commit

Permalink
fix error message when image dims are wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
meinstein committed Jan 11, 2018
1 parent 8d5ffeb commit 258c744
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/load-image.js
Expand Up @@ -11,15 +11,15 @@ export default function loadImg(dataUrl, dims) {
// listen for onload event
img.onload = () => {
// validate the min and max image dimensions
if ((img.width < minWidth) || (img.height < minHeight)) {
if (img.width < minWidth || img.height < minHeight) {
reject(new Error(`The uploaded image is too small. Must be at least ${minWidth}px by ${minHeight}px.`))
}

if ((img.width > maxWidth) || (img.height > maxHeight)) {
reject(new Error(`The uploaded image is too large. Must be no more than ${minWidth}px by ${minHeight}px.`))
if (img.width > maxWidth || img.height > maxHeight) {
reject(new Error(`The uploaded image is too large. Must be no more than ${maxWidth}px by ${maxHeight}px.`))
}

resolve(img)
resolve(true)
}

img.onerror = () => reject(new Error('There was an error uploading the image'))
Expand Down

0 comments on commit 258c744

Please sign in to comment.