How do I save and retrieve CKEDITOR media (images and video) on a CDN? I am using CKeditor, and I need to add media in content. I have enabled the media in the CKeditor configuration.



Then I upload an image:





The image is being added:



Checking the path for the image :



It gets saved in the local server, while I want it to be saved in a CDN. 

I am also using the Media module and CDN old S3 module. which saves all the media in the CDN, but the images for CKeditor are saved on the local server.

Currently, it is saved in the base path (eg. https://drupal.stackexchange.com/). I want it to be saved and retrieved from my CDN.

I did find the  Uploadcare : Add media from anywhere plugin, but I don't understand how to use it; I  think it has its own CDN, but I want it to use my own CDN.

Modifying the core is not recommended and it is not the best practice, how do I achieve it in efficient way.
How do I save images added from CKeditor on a CDN instead of the local server?
Until CKEditor developers implement the functionality, you could create a custom module that:


on node add/edit you loop thru all fields using CKEditor and crawl each images/videos
detect if the images are already on the CDN
if not, upload the images/videos on the CDN
replace the images links with your new CDN links
save the node


I hope it will help you.