You are here:
  1. Home
  2. Blog
  3. WordPress
  4. WordPress Multisite Shared Media Library

WordPress Multisite Shared Media Library

 |  WordPress

Dearest WP users and developers, this post is a plea for help.

I am trying to create a WordPress Multisite Shared Media Library. I want to be able to upload content (PDFs, images etc) to the main blog of a WP Multisite install, and access that media from other blogs on the same network (there’s a plugin for this already). However, I need to be able to attach that media to a post/page, NOT just insert it. I want to do this without duplicating the actual file… i.e. if I replace the original file, all posts/pages that have the media as an attachment will be looking at the new file, not a copy of the old file.

I have already created the functionality to duplicate the database info (copying from attachment info from the main blog to the sub-blog) allowing WordPress to see my new child attachment. The attached media shows up in the Gallery for the relevant new post/page that I’ve attached it to. The GUID for the attachment points to the file in the original location on blog #1. However, WordPress does some fancy footwork with Multisite URLs to turn the file path into the sub-blog URL upload path instead.

File location is actually "URL/wp-content/uploads/2012/11/Chrysanthemum.jpg", not "URL/files/ etc..."
File location is actually “URL/wp-content/uploads/2012/11/Chrysanthemum.jpg”, not “URL/files/ etc…”

I am fairly sure I need to filter upload_dir (add_filter('upload_dir' ..) to make WP look in the right place, but I don’t know how to do this conditionally for certain attachments, without affecting the attachments that need to be (or are already) loaded to the sub-blog.

I am hoping that all makes sense, and that someone out there has an idea of how to help! :)

Jem Turner +44(0)7521056376

Comments are closed.

Follow on Instagram