Is it possible to share WordPress media files among different domains?

The short answer is that this cannot be done with vanilla WordPress (I know, I tried). However, a little coding could make that happen.

Images are stored in WordPress as a built-in post type – Attachments. This is what you would need to update on the remote sites with details of the CDN image as the subject.

My approach (that I have considered doing for a multisite) would be this.

Write a small plugin that can add attachments programmatically when notified of new ones. I would provide a white list of sources (my sites) and if the ping came from said site, and the image was found on it, then the attachment would be made locally with the image either copied to local or remotely stored (say in your CDN).

As I have recently learned, you can create custom JSON endpoints in WordPress. These endpoints would be what you would need to have the sites “talk” to each other to share updates about new media.

If you do this, be careful to lock those endpoints down tight. If you are not careful with incoming data, sooner or later some malicious so-and-so will cause you to have a very bad day. This is why I suggest white-list only. That or some sort of signed certificate using public/private keys.

I have seen a lot of people asking for shared media in a lot of places. Whoever sat down and got something like this working would be most popular.

I hope that helps.