+1 great job The only suggestion I'd have would be to keep the function in the master-admin slide and only use it in other templates if possible. For example I see a similar function in option_config.html (#upoloadFile) that would use these same checks.
Perhaps it is time we have our own .js file with these things and just apply them as needed, it should be easy enough to convert this code from an anonymous function to something called FileUploader() or similar.
+1 LGTM
I agree with Simo, it might make sense to make this available in a library.
It would be nice but let me point out that the two functions, while similar, actually do quite different things. The uploadFile call slurps in the file for image mime types only and then puts that image as a thumbnail onto the screen.
The new function just reads the file and checks the result to see if there was one and raises an error if not.
So I can see generalizing the current patch for future use without affecting the file uploader one. This is just beyond my meager Javascript skills: being able to register this calback for any file input type by id. Patrick may know of a way.
I'm just happy to have some verification, since generalizing is not obvious I say let's put this in now and worry about generalization later if the need arises.
Thanks for the good work Rob!
I was just thinking you'd want to check if the file is readbale in both cases, not a full merge of both functions.
That was easy enough to do both for the new SP case and when changing the portal image.