Fixes #5043 Photo uploading from ckeditor

This is a rebased version of #5176

I need to update the admin view and use the new file matrix class, plus some other small clean up.