WordPress Multisite Media Sharing

If you are using a network to publish multiple sites, reusing media library across means that a WordPress multisite media sharing is for you

14 mins read
Standard WordPress media modal showing the default media library interface. In a multisite environment, media uploads are siloed—stored in separate database tables and physical /sites/{site_id}/ directories—preventing users from accessing media across subsites.

If you are using multisite to publish multiple sites, then reusing media across your sites either means inserting with a URL or loading the image up twice. Hardly satisfactory. This WordPress guide will look at sharing pictures, video, and audio across your site, saving you considerable time, trouble, and disk space by sharing multisite network media library.

WordPress Multisite Media Sharing Network

When you set up a multisite network, you can use a centralized dashboard to manage multiple websites. Sometimes, a multisite setup enables you to share resources among your network’s sites, such as themes.

However, each site on your network will still have its own media library. This can be a hassle if you plan on re-using images between multiple locations. If that’s the case, you’ll need to upload them repeatedly and keep jumping from one dashboard to the next.

A central media library that all your sites can access solves those problems. While this is a niche feature, it can be constructive for multisite owners to organize their media files. Plus, it’s pretty cool, which is one of the reasons we wanted to show you how it works.

Multisite Media Library Plugin

Network Media Library is a plugin for creating a shared library across multiple sites. It works by designating one of the sites of your network as a ‘central library.’ That site will still work as usual, except any file you upload will also be available to other websites within the network.

The plugin is also plug-and-play (pardon the pun), so it’s easy to test. We should also mention that while the plugin is currently only available on GitHub, we can tell you it works as well as the one you’d find on WordPress.org.

Key Features:

  • Create a networked library for your multisite media setup.
  • Designate a site within your network to act as a central media library.
  • Easy to install and use.

How to Create a Networked Library for WordPress Multisite (In 3 Steps)

As we mentioned earlier, the plugin we will use is simple to set up. We’ll now walk you through the process of installing the plugin from GitHub and then test it to check that it’s working correctly.

WordPress Multisite Network Media Library Plugin

Downloading a plugin from GitHub is almost the same as from the WordPress.org repository. First, go to the plugin’s GitHub repository and look for the Clone or download button at the top right of the screen. Click on it and select the Download ZIP option:

You can now open your Multisite dashboard and navigate the Plugins > Add New tab. Select the Upload Plugin option and add the zip file you downloaded a minute ago: Easy as pie, right? Now, remember to activate the plugin for your network and move on to step number two.

Uploading Media Files

As you may know, your multisite dashboard doesn’t include a gallery tab. To get around that, the plugin designates one of your websites to act as a central library instead. The plugin default picks up whichever site has the ID number two.

In most cases, ID number two should correspond to the first site you created after setting up your network. For our tests, we set up a multisite dummy network (using Local by Flywheel) and added a few sites to it. In the image below, website one corresponds to ID number two:

You can also check the ID of your sites by hitting the Edit option for any of them, which will open their settings. If you take a look at the URL for that page, you’ll see an ID number at the end of it:

With that out of the way, navigate to the dashboard of the site you’ll use as your central gallery. Once you’re in, go to its Media tab and upload any image you want to test if the plugin is working. If you have a picture of a puppy, we suggest going with that one, though the WordPress multisite network media:

Next Steps on WordPress Multisite Media Sharing

Once your picture is uploaded, go ahead and access the dashboard of any other site within your network and open its media library. You should now see your test image appear here. If you’re curious, like us, you might wonder what happens if you upload a picture to the media library of site number two. We gave that a try:

After checking the media library of site number one, we can confirm that the second image also appeared in every site’s library. The takeaway is that once you install the plugin, all connected site’s media libraries will be synced up. However, your multisite network will only store a single copy of those images in your central library.

One Copy of the Uploaded File

To test whether the plugin worked correctly, we dug into our Multisite network’s directory. That means we went into our Multisite root folder and the wp-content/uploads directory. As you can see below, there are two folders inside, one for each of the websites within our test network:

Since we’re using a local setup, we ran our tests using Windows Explorer instead of File Transfer Protocol (FTP). That aside, we checked the uploads folder for website number two, and we found it to be empty: However, here’s what we found when studying the media folder for website number one:

If you recall, we uploaded that first image you see to the left to website number two. The plugin then moved it over to site number one and provided number two with access to that central library.

As you can see, the plugin works strictly as intended and doesn’t create additional copies of any of your images. As such, you can upload as many puppy photos as you want!

Why are the Media Libraries Divided?

WordPress cannot share multiple site elements (posts, media, etc.). A multisite installation is intended to facilitate the creation of numerous WordPress websites in one technical building. However, these websites should be able to be operated by different administrators or even organizations.

As a result, WordPress has chosen not to utilize a media sharing mechanism between your sites. All of the files should be kept separate, as there may be sensitive information in them. Every place in a multi-site should be isolated and have no other dependencies.

If the individual sites were not out, this would also cause technical difficulties when attempting to transfer the site out of the WordPress Multisite later.

Reasons To Not Use WordPress Multisite Media Sharing

Plugins like shared-media-library facilitate the use of a shared media library for all websites in a WordPress Multisite. Plugins like this undermine the core design of WordPress.

This was not up. For instance, WordPress’s management of upload rights has limits, making it impossible to implement significant limitations in a shared media library.

Additionally, plugins that utilize this functionality must introduce their APIs, which can be incompatible with plugins like Real Media Library. Compatibility issues and malfunctions with other plugins and your theme may occur.

Is There a Way to Still Fix The WordPress Multisite Media Bloat With The Shared Library

Multisite shared media library solution for WordPress with zero-duplication

Though managing media in WordPress multisite networks is quite simple, but, as the network of your sites scales, it bloats and becomes tough to manage. But at first it seems like yes, having an isolated media library for each sub-site keeps every sub-site’s team organized within their own boundaries.

Still, when you need to upload the same logos and featured images again and again for dozens of sites, the flaws become quite obvious after that.

I mean, instead of using the same single physical file, administrators of each sub-site are now forced to upload the same image repeatedly. What do we have as a result? A severe server disk space bloat. Especially, if there are original images with up to 10Mb of size. Sometimes it even causes inconsistency in company branding, by the way.

Below, in this guide, we will take a quick look at the architectural reasons why WordPress Multisite isolates your media in the first place, why old-fashioned “sync plugins” is not a solution to it and how to choose a proper shared, zero duplication workflow (which will perform well in an enterprise production environment).

The Architecture of WordPress Multisite Media Isolation: Why and How?

As you may have guessed it by now, WordPress Multisite installation is engineered around strict site independence. This design makes sense, it not only prevents unintended data exposure, but also simplifies each site management, backups, etc. 

The following isolations are enforced as the root levels:

1. The File System: Partly-isolated Upload Directories

Even though each sub-site of a WordPress multisite uses the same /wp-content/uploads directory (it can be changed by the way), but after that, each subsite stores its media in an isolated folder inside it, in most cases, the structure will look like: /wp-content/uploads/sites/{site_id}/. What does it mean? Right, Subsite A literally can’t access the physical files stored in Subsite B directory.

2. The Database: Separated Tables

Physical server files aren’t the only thing that is fully isolated in the WordPress Multisite network, the isolation goes further. Each subsite uses its own specific database tables, including the wp_{site_id}_posts and wp_{site_id}_postmeta tables (where media files are stored). Even if you manually upload the exact same 2Mb hero image to 50 different subsites, the WordPress database treats them as 50 completely separate, unrelated items. Because of this, simply by design, there is no native way to share media globally.

The Danger of the “Sync Plugin” Workaround

Right after launching a network site, it is an important commitment to whether to accept or decline the idea of media files isolation. Because, if done wrong, it may cause massive operational liability in the future. Usually, administrators immediately look for a plugin to solve this and make a critical architectural mistake: they install some kind of a “Media Sync” tool plugin.

Why? Simply because syncing plugins do not fix anything. They just allow you to automate the inefficiency.

So, you upload a 2Mb image to your main site (our example image, let’s say), then a sync plugin automatically (or manually depending on the configuration) copes the physical file to all your 50 subsites, which instantly turns a 2MB upload into 100MB of wasted server disk space. Also, let’s not forget, that depending on the WordPress theme you’re using you may have custom image sizes generated (medium, large, thumbnail, etc.) Of course, other uploads have a compounded effect. Just imagine how it may inflate hosting costs? Or, how routine server backups will turn out into massive bloated operations?

The Architectural Fix: A Database-Only Syncing System

So, what to do then?

To actually solve the multisite media problem once and for all, you need an architecture that provides a single central library, which can be accessed across all subsites in your network, but, and it is crucial, with absolutely zero file duplication. Good news that we can bypass the native isolation by using database indexing.

Instead of syncing (copying) physical files to all of 50 subsites, we only copy a small part of the attachment database information from wp_posts table and almost or completely skip the wp_postmeta table. Well, the database will still bloat a little bit, but it is not comparable to syncing a media file completely.

The first time we found this practice was in the Multisite Shared Media Library plugin (by Rudrastyh). After a week of thorough testing we came to a solution,that this tool exactly solves the multisite media fragmentation without bloating the server.

Phase 1: Installation and Indexing

Honestly, there is not much to say here anyway, you will just activate this tool as any regular WordPress plugin for a multisite network, meaning, we need to click “Network-activate”, not simply “Activate”. What we also do like is that the tool doesn’t force you to index the whole network right after the activation. You remember, that we have 50 sites after all, it will be quite the pain to run this indexing scan even if it is performed by AJAX and doesn’t disrupt the network, etc. So, the tool only scans /sites/{site_id}/ directory of the sub-site you’re currently working on and only the uploads that popup in your media modal. In other words, if you have 100K files, but only 80 are displayed when you insert an image – those 80 are going to be indexed immediately. And so on. 

And yes, the physical files will remain completely untouched. Just one extra database table is created – “wp_network_media_placeholders” which stores media placeholder indexers. But it is incredibly simple:

database indexing

Can we consider this a database bloat? I guess not.

Phase 2: The Cross-Site Media Modal

Now, once we finished looking into the architectural stuff, let’s take a look at how the editorial workflow has been changed. Spoiler: completely.

The native WordPress media modals on any subsite work as usual except one small but very interesting detail, it is not possible to use the “Shared media” tab at the top of the interface.

cross-site media modal created with Backbone.js

Inside this tab live all the media files: images, videos, audio files, PDFs, etc. from the selected global media website of the network. This custom tab hooks directly into WordPress code backbone.js media modal, meaning that it works natively with Gutenberg, Elementor, and custom fields.

Phase 3: Zero-Duplication Insertion

When a user selects an image from the “Shared Media” tab and inserts it in Subsite B, Subsite C, etc., it generates a virtual attachment linking to its original physical file and database data. Zero physical duplication. 

From our perspective, it looks like this architectural solution was inspired by how the original WooCommerce HPOS migration is implemented. It also has some virtual orders in the wp_posts table while utilizing brand new database tables specifically for high performance order storage.

The Single Architectural Limitation

This database managing system, at this point, definitely shows itself as the most efficient way to manage network media, but it comes with one hard rule regarding network exports.

If a subsite owner intends to export a subsite out of the multisite network to become its own independent, standalone installation (e.g., migrating network.com/subsite-b to subsite-b.com), the connections will break. Because Subsite B was relying on the physical files stored in Subsite A’s uploads directory, the exported standalone site will be missing its images.

But not fully, only those images that are used on this subsite as IDs. In other words, the images in post content will remain unharmed.

If your long-term business model relies on constantly spinning off WordPress Multisite’s subsites into independent sites, then a media sync tool is still required. However, if your goal is to work with a unified network, then this method of organizing a multisite media library is definitely worth considering.

Frequently Asked Questions

Will a database-indexing system slow down my network?

No. The database indexing system uses an optimized global index table (wp_network_media_placeholders). Plus, the plugin relies heavily on WordPress object caching. But worry not, it is configured that way, so the cache is updated accordingly and will not serve already deleted or replaced media files.

Does this integrate natively with Elementor and Gutenberg?

Yes. It is thanks to the Backbone.js media modal which is used not only in Gutenberg but also in many popular plugins like Elementor, ACF, Divi, etc. Once the shared media tab is added to this media modal, it will appear in all the third-party plugins that support it.

What happens to the media if I export a subsite to an independent WordPress installation?

Because files are not physically duplicated, if you extract network.com/subsite-b and move it to a completely standalone site, many but not all images it “borrowed” from Subsite A will break. Featured images, product images and images in custom fields will break and will require a synchronization tool before migrating. But the images in the post content will remain intact.

Is it safe for massive networks?

It looks like it. From what we have seen in the source code of the plugin, it seems like it will handle massive networks, but we didn’t have a chance to test it on production for such networks. However, maybe you will need to ask the plugin developer (Rudrastyh), probably he already had some case where his customers implemented the plugin on massive networks.

Why is WordPress Multisite built to isolate media in the first place?

This is all up to WordPress core prioritizing strict data separation for managing simplicity and for privacy/security reasons.

WordPress Multisite Media Sharing Final Words

Efficiency is key when you’re managing multiple WordPress websites. Using a centralized media library for your sites can help you save time and avoid having to upload files over and over again. Three steps to create (and test) a networked library for WordPress are: Install the Multisite Shared Media Library plugin. Test the plugin by uploading a media file to a multisite network. Check if there’s only one copy of the file you uploaded.

Claudio Pires

Written by

Claudio Pires

Co-founder of Visualmodo, Claudio is a senior web designer and developer with over 15 years of experience in content creation and technical support. A trilingual expert fluent in English, Portuguese, and Spanish, he brings a global perspective to digital design. As an active YouTuber and industry specialist based in Brazil, Claudio is dedicated to pushing the boundaries of web development and sharing his insights with a global community.

Topics
Continue reading Why Online Security Never Been More Essential
Continue reading The Revolution of Online Education With BitDegree
Continue reading How to Market Your WordPress Site Better for Higher Conversion
Continue reading WordPress Database Files Replacement
Continue reading How to Pick the Right eCommerce Theme

Recommended For You