Fixes #5043 Photo uploading from ckeditor

This is a rebase of #5653 and replaces #5805

To test, deactivate and activate the ckeditor plugin.