Currently you can only upload image files of type .jpg, .jpeg, .png and .gif, and the max file size allowed is 5MB. Error handling has been re-worked to support client side checking on these file constraints first and only sending valid files to the server side. Server side validation remains of course.
All images uploaded are resized to different sizes, small, medium, large and original, the only exception is .gif files, only originals are saved and no resizes. This is due to a remaining technical issue I yet to be able to solve with Magick.NET, when resizing gif files it takes a long time and the resized file size is larger than the original file. I put in a temporary fix till I figure out how to resize animated gif with Magick.NET or another library.
Uploading files by clicking the UPLOAD button has been re-worked for Microsoft Edge. Edge does not work with file input
onchange event, so I implemented it with
addEventListener instead. I also added file input tag in the html markup instead of dynamically creating it in js.
Finally I improved on slug generation to make duplicates unique work better. Posts and files uploaded are siloed with time, for a post you have year/month/day as part of its slug and for files you have year/month in its path. So the chance of file name and post name collisions should be small. But still it could happen, for example, you uploaded a file earlier this month and later you upload another file with the same name, what do you expect should happen? Rest assured, I don't replace the existing file, instead I append a number to the file name, like my-file-2.png, to resolve the conflict. This number starts at 2, so if you upload another one you'll get my-file-3.png and so on.