Sanitize file names that would break the markdown preview. (Remove round and square brackets)
Prevent uploading image if the file size exceeds 10 MB, because processing sizes larger than that takes a long time and might cause memory problems.
Scale the image down (without changing the aspect ratio) if width or height is larger than 1024 pixels.
If the user provides a web url instead of uploading an image, the file size does not get checked. Providing urls with very large images (~50 MB) does not hurt the performance, as they are handled and scaled by the browser's native <img> component. However, the content of the image will still be downloaded no matter how large the image in the provided url is. This might increase data usage drastically on the client side. We cannot make a HEAD request (to get the file size) from the browser because of the CORS policy.
One possible solution to this issue might be checking the image links in the backend, and not rendering the image, rather showing only the url, if the file is larger than a certain size.
Solves #48 and #97:
If the user provides a web url instead of uploading an image, the file size does not get checked. Providing urls with very large images (~50 MB) does not hurt the performance, as they are handled and scaled by the browser's native
<img>
component. However, the content of the image will still be downloaded no matter how large the image in the provided url is. This might increase data usage drastically on the client side. We cannot make a HEAD request (to get the file size) from the browser because of the CORS policy.One possible solution to this issue might be checking the image links in the backend, and not rendering the image, rather showing only the url, if the file is larger than a certain size.