I have a multisite install -- set for using subdomains and mapped domains -- with websites from several clients on it and I would like to create a copy of each and any uploaded media file of my clients subsite to Main website (or a specific subsite which I will call Repository). i.e. client X uploads a photo, it should be copied to my main website (or Repository website).

What would be the best way to go, performance and security wise?

  1. subsites ping the Main or Repository website with a custom endpoint to let it know there's new media and Main/Repository website copies the files using media_handle_upload or media_handle_sideload, for example

  2. Allow subsites upload Main/Repository website using WP REST API media endpoint

Giving some context and use case:

And I am using a cloud service for image optimization, which limits each account and API Key to 1 domain. I want to avoid the hassle of creating and managing an account and an API key for each client of mine and, therefore, I want to use Main website for optimizing all images with one account/API key to optimize the images

Important notes:

I don't want any "ready" code. I am really interested in the ideas and considerations for each way.

There are similiar questions, but they are not exactly the same problem and use case because...

Network Shared Media and plugins like it

Plugins like Network Shared Media don't solve the problem. I don't want clients seeing each other files and the optimization plugin won't see the images in the /sites/site_id/ directory, it will optimize images only in the folder for the main website.


I want to do it programatically, not using export/import. As soon as the client uploads something to his/her website, it copies to the Repository site.

  • Not to be too obvious, but there is the option to Export and Import under Tools, which works for media files. – Nicolai Jan 9 '18 at 14:02
  • Maybe it was too much implicity, but I wanted to do it programatically. Whenever the client uploads something, it copies right after it. – Celso Bessa Jan 9 '18 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.