Yes, it’s possible to use a shared folder for images across all the subsites in your multisite network. You can achieve this by adding a custom filter to your WordPress multisite installation.
To do this, you can add the following code to your wp-config.php
file or create a custom plugin and place the code inside it:
function ms_shared_media_uploads($dirs) {
$dirs['baseurl'] = network_site_url() . '/wp-content/uploads';
$dirs['basedir'] = ABSPATH . 'wp-content/uploads';
return $dirs;
}
add_filter('upload_dir', 'ms_shared_media_uploads');
This code will change the upload directory for all subsites to use the main site’s uploads
folder, so all subsites will share the same folder for their media files.
However, keep in mind that using a shared folder for media across all subsites can lead to potential issues:
- If you ever decide to separate a subsite from the multisite network, you’ll need to manually move the images belonging to that subsite.
- If two images from different subsites have the same filename, one of the images will be overwritten.
- Managing media files can become more challenging as your network grows.
That being said, if you still prefer to use a shared folder for all images, the provided code snippet should help you achieve that. Just ensure you take regular backups and monitor your media library carefully.