2

I have multiple Wordpress instances that live on separate domains (not a multisite installation).

Since they provide the same content in different languages I'd like to share the images among these instances. Ideally these Wordpress installations would share the same Media Library so that I have to upload the files only once and they would be available on the other site as well, even served by the same CDN and sharing the same URL.

So for example I upload Image1.jpg on site Example.com and this gets copied to the CDN by W3 Total Cache which serves the image from MyCdn.com/static/Image1.jpg

The other site Esempio.it would have the Image1 already available in the Media Library without needing to upload it and be able to serve the same image from the same URL MyCdn.com/static/Image1.jpg

Since both sites live in the same server I was thinking of using the Store uploads in this folder setting from Media Settings and have that target folder be in fact a symlink.

What's the suggested best practice for this scenario? The space needed is not a real concern but I was more concerned by ease of maintenance.

Thanks!

  • Sharing the folder may work... however I don't believe the other installs will 'pick up' anything not uploaded through their admin interface. wordpress.org/extend/plugins/add-from-server I've used this plugin in the past to grab ftp'd media, it may help you as well. – Rev. Voodoo Sep 23 '11 at 11:03
  • I know you said you don't run multisite but this question on SO might still help – Cilvic Sep 23 '11 at 14:11
  • I don't currently use multi-site but could consider it if it made sense. I'm on WP 3 anyway. Thanks for the pointer. I'm not sure though I should run multi-site, I'm afraid of how Google would evaluate such a site if I were to run multi-site with the domain mapping plugin. Getting penalized for being lazy is not my style ;-) – Lorenzo Sep 23 '11 at 19:48
0

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.