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.
Some browsers (at least recent Chrome versions) automatically take
image metadata into account when drawing images into a canvas.
There seem to be no way to prevent that behavior, and the only
way to detect it seems to compare with a known image.
See: https://github.com/w3c/csswg-drafts/issues/4666
Solution adapted from: 1e4df70782
* [WiP] Add a confirmation modal before logging out from the web interface
* Add confirmation to logout link in getting started footer
* Please CodeClimate
* [WiP] Show host for “misleading” links
* Disallow misleading targets which domain names are prefixes of link text
* Move decodeIDNA to app/javascript/mastodon/utils
* Add support for international domain names
* Change link origin tag color to darker text color
* Handle links to domains starting with www. as shortened by Mastodon
* [WiP] Ignore links that cannot be misread as URLs, rewrite other links
To improve the way super tall or super ride images are treated, the
numbers remain the same, 1280x1280 and 400x400, but if an image
is less in one dimension than the other, the other can become larger
Thanks to @WAHa_06x36@mastodon.social for the tip
- Use URL.createObjectURL (replace from FileReader)
- Use HTMLCanvasElement.prototype.toBlob
(replace from HTMLCanvasElement.prototype.toDataURL)
- Use Promise (replace callback interface)