In this tutorial, we will talk about ways of managing media files when you’re running multiple websites within a single WordPress Multisite network. Whether you’re a WordPress Developer, Plugin Developer, or Full Stack Developer, understanding media handling is essential for building scalable systems.
By the way, if you’re not 100% sure what a multisite network is, then you’re probably running multiple standalone sites.
Long story short, I will show you how media files in multisite networks are handled by WordPress, how to set up centralized media management across your network, and also how to organize media efficiently. This is especially useful for a Woocommerce Developer or Mern stack Developer working on large-scale applications.
How Media Files Are Stored in WordPress Multisite
First of all, it’s important to understand that media in WordPress is not only files, but also a custom post type called “attachment,” which is stored in the database along with all required metadata.
Files vs Database
Files:
All uploaded files are stored in the uploads directory as usual. However, in a multisite network, they are separated into folders:
/uploads/sites/{id}
Where “id” is the subsite ID.
For example:
- Subsite ID 7 →
/uploads/sites/7
What about the main site?
Its files are stored directly in /uploads/ without /sites/1.
Database:
Since media is a custom post type, its data is stored in:
wp_{id}_postswp_{id}_postmeta
For example, uploading media to subsite 7 stores data in:
wp_7_postswp_7_postmeta
This structure is important for any Plugin Developer or Full Stack Developer working with custom queries or performance optimization.
By default, there is no direct way to access media files across subsites.
A Way to Use a Shared Uploads Folder Across All Subsites
If you don’t like the default structure where uploads are separated into multiple folders, you can force all subsites to use a single shared uploads directory.
Here is the code snippet:
add_filter( 'upload_dir', 'rudr_shared_uploads_folder', 25 );function rudr_shared_uploads_folder( $uploads ) {
$uploads['basedir'] = ABSPATH . 'wp-content/uploads';
$uploads['baseurl'] = network_site_url() . '/wp-content/uploads';
return $uploads;
}
Make sure this snippet is network-activated.
What this snippet does:
- Forces all uploads into
/uploads - Overrides
wp_upload_dir()behavior - Requires manual migration of old files
- May overwrite files with the same name
- Does NOT create a shared media library UI
This approach is often used by a WordPress Developer or Mern stack Developer for simplified storage, but it comes with limitations.
Using a Global (Centralized) Media Library in WordPress Multisite
Now let’s explore a more advanced solution.
You can set up a centralized media library in two ways:
Option 1:
Use one subsite as the main media hub for all others.
Option 2:
Keep individual media libraries but add a “Shared Media” tab.
This can be implemented using a multisite media plugin.
When you add an image (or another type of media file) anywhere on your website, you can select media files from the centralized (shared) media library.
Both options can be achieved with the Multisite Shared Media Library plugin.
Choosing a Centralized Media Subsite (Optional)
By default, the main site (ID = 1) is used as the global media library.
But you can change it using:
add_filter( 'rudr_sml_network_library_id', function( $centralized_library_id ) {
$centralized_library_id = 7;
return $centralized_library_id;
} );
For example, this sets “Site 7” as the global media library.
A Plugin Developer or Full Stack Developer might use this to create custom workflows across enterprise-level networks.
Displaying Shared Media vs Replacing Local Libraries
You can configure how the shared media behaves:
- Show in a separate “Shared Media” tab
- Replace local media libraries completely
This is managed from:
Network Dashboard → Settings → Network Media
If using a shared tab, all subsites can access global media without losing local control.
For example, if I select the “Display shared media in a separate tab” option, then I will have the “Shared media” tab available on all subsites except the main site:
What about the uploads folder? Well, obviously, the uploads directory of a subsite, which is chosen as a centralized library, will be used. In other words, by default, it is going to be /uploads; however, if you changed it to “Site 7” here, then it is going to be /uploads/sites/7, but it can still be modified with the code snippet above.
Why This Approach Works Better (Technical Insight)
Many older plugins rely on:
switch_to_blog()restore_current_blog()
These cause:
- Missing media in some cases
- Performance issues
Modern implementations avoid excessive switching and rely on optimized database queries and caching.
This is especially important for a Woocommerce Developer handling large product catalogs or a Mern stack Developer building hybrid architectures.
Organizing Network Media Files With Folders
Managing media becomes easier when you use folders.
You can organize files within each subsite using a media folder plugin.
Benefits:
- Better structure
- Faster access
- Cleaner UI
- Easier management for large teams
If combined with a centralized media library:
- Shared folders appear across subsites
- Media becomes easier to reuse
- Organization improves significantly
This is highly recommended for any WordPress Developer or Plugin Developer working on content-heavy platforms.
Best Practices for Managing Media in Multisite
To make your system efficient and scalable:
- Avoid duplicate uploads across subsites
- Use centralized media when possible
- Optimize images before uploading
- Maintain consistent naming conventions
- Avoid excessive plugins
- Use caching for performance
A Full Stack Developer or Mern stack Developer can further enhance performance using CDN integration and API-based media handling.
Final Thoughts
Managing media in WordPress Multisite is not difficult, but it requires the right approach.
Whether you choose:
- Default isolated media
- Shared uploads directory
- Centralized media library
Each option has trade-offs.
For most growing networks, a centralized media approach works best—especially when handled by an experienced WordPress Developer, Woocommerce Developer, or Plugin Developer.
With the right setup, your multisite network becomes easier to manage, faster to scale, and more efficient in the long run.
Hi and welcome! I’ve spent more than 7 years helping WordPress users with easy-to-follow guides, tutorials, and practical tips all completely free.Need expert developer help? I’m just a message away.