最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

WordPress Multisite: How to make all media library items available for every site?

programmeradmin0浏览0评论

I have a WordPress Multisite where the main site has all the images in the media library I want to use in each additional site, however I can't figure out a way to get all the images to show up in the additional sites' media library.

I've looked at the Network Shared Media plugin but it doesn't allow me to add the images where I need them. Only in post/page content.

I have a WordPress Multisite where the main site has all the images in the media library I want to use in each additional site, however I can't figure out a way to get all the images to show up in the additional sites' media library.

I've looked at the Network Shared Media plugin but it doesn't allow me to add the images where I need them. Only in post/page content.

Share Improve this question edited Aug 23, 2017 at 21:45 Casey asked Aug 23, 2017 at 21:39 CaseyCasey 711 gold badge1 silver badge3 bronze badges 1
  • This isn't easy because media libraries don't show files, they show posts of type attachment. The fundamental problem here is that you need an asset manager/catalog, there may be external services better suited – Tom J Nowell Commented Aug 23, 2017 at 22:17
Add a comment  | 

3 Answers 3

Reset to default 1

As mentioned in a comment, media is actually a special 'post', so the media only belongs to the sub-site, and is not easily accessible from the subsite.

But there are methods to go though all subsites and display the media from all subsites on a single page in any subsite. I do this with my Multisite Media Display plugin (https://wordpress/plugins/multisite-media-display/ ), which first enumerates all subsites into an array, and then queries each subsite to display the images within that subsite. It does the work via a shortcode you display on a post/page. I use it to monitor the media on all subsites to ensure that the media meets the site's standards. And, if logged in as the super-admin, each image links to it's 'edit' page, which allows me to rotate pictures as needed.

As with all plugins, the code is 'open source' (and the plugin is free/full-featured), so if you wanted to 'roll your own', you could use the code processes that I use (which I gathered from the googles, and then tweaked the code into my plugin). I couldn't find a plugin that did what I needed, so wrote it for my own use. (And then I made variations to display posts or comments from all subsites via a shortcode.)

The plugin has options to specify subsites and other parameters, so you can 'filter' the output to what you need.

You are welcome to use the code in the plugin to make your own plugin that will do exactly what you need.

@Casey did you find a solution yet?

I developed and maintain a plugin that should address your case quite well if I understand it correct.

It replicates the uploaded media library entry to all the sites using built-in WP functions, making them native media objects on each site. However, only a single copy of the actual file is stored on the disk to save disk space.

It is also possible to replicate all existing images throughout the network. Admin can choose if the media should also be deleted across the network, or per-site.

It can be bought from CodeCanyon: https://codecanyon/item/wordpress-multisite-shared-media/19306250?ref=aikadesign

P.S. I am affiliated with the product, which means that I get paid if someone purchases it. I understood it is okay to promote own product if it answers the question and if the affiliation is clearly communicated. I think the conditions apply here.

I came across the exact same issue. Try this... Add the following to your .htaccess file in your site's C-PANEL File Manager where your multi-site is installed, replacing other WordPress rules with:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

You can get this code straight from the Network Setup settings.

发布评论

评论列表(0)

  1. 暂无评论