I need to store some small images as Base64 in a document created using the Rich Text Editor.
I'm using the ActionComplete event handler to retrieve the blob, convert to Base64 and store as the SRC of my element, so the basic functionality is working correctly.
But I also need to validate the size of the image to prevent the browser crashing or unwieldy size of the final document.
I can't use the ImageUploading event because this is not invoked when I'm not uploading the image to the server as a separate action.
The ImageSelected event does not seem to be reliable.
If I select a 9MB file using the toolbar, I can see the event fire and get cancelled, the file does not show in the file selector dialog, but when I click the Insert button the image appears in the RTE and then my Chrome session is unresponsive presumably because of the memory consumption. It seems that the cancel argument in the event is not completely cancelling the image selection.
If I drag and drop a 9MB file into the RTE, the image appears and Chrome session stops working again. It seems that the ImageSelected event did not fire at all.
How can I validate the size of an image that I'm going to be managing as Base64?
How can I explain what the problem is to the user when they try to upload a large file? Is it possible to customise the error message in the Insert Image dialog?
Thanks in advance
Andrew