mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 15:09:29 +00:00
Fix uninformative error message when uploading unsupported image files (#13540)
Attempting to upload image files that the browser is unable to load results in “Oops! An unexpected error occurred.” This commit changes the error handling so that an unprocessable image results in the file being sent anyway, which might cover a few corner cases, and provide a slightly better error message.
This commit is contained in:
parent
c955f98d36
commit
be637146f3
|
@ -138,7 +138,7 @@ const resizeImage = (img, type = 'image/png') => new Promise((resolve, reject) =
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default inputFile => new Promise((resolve, reject) => {
|
export default inputFile => new Promise((resolve) => {
|
||||||
if (!inputFile.type.match(/image.*/) || inputFile.type === 'image/gif') {
|
if (!inputFile.type.match(/image.*/) || inputFile.type === 'image/gif') {
|
||||||
resolve(inputFile);
|
resolve(inputFile);
|
||||||
return;
|
return;
|
||||||
|
@ -153,5 +153,5 @@ export default inputFile => new Promise((resolve, reject) => {
|
||||||
resizeImage(img, inputFile.type)
|
resizeImage(img, inputFile.type)
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch(() => resolve(inputFile));
|
.catch(() => resolve(inputFile));
|
||||||
}).catch(reject);
|
}).catch(() => resolve(inputFile));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue