views:

36

answers:

1

Hi,

i created a Worpress 3 Multisite with 5 Sub-Blogs. Is it possible to share the same Media-Library in this Blogs?

i changed upload_path in wp_1_options and wp_2_options for example and also in my backend in "Super Admins" Menu but it has no effect.

The files are uploaded to wp_contents/blogs.dir/1-2-3/files and the options have no effect.

any ideas? thanks!

A: 

One way around is to hook onto the load events of all media admin files, and switch to the main blog using switch_to_blog(1).

This would mean in any blog admin, the media library will always run as if it were on the main blog.

Note that a couple caveats include;

  • The media library for all blogs is stored in the main blog database table.
  • You may run into problems with inserting media into posts outside the main blog admin
  • You will run into problems with inserting galleries into posts outside the main blog admin
  • User permissions may be false positives or negatives

My best advice would be to use the code example below, and have a good play around with blog admins, logged in as different users, with different roles, and see what happens.

function use_main_blog_library()
{
    switch_to_blog(1);
}
add_action('load-media-new.php', 'use_main_blog_library');
add_action('load-media-upload.php', 'use_main_blog_library');
add_action('load-media.php', 'use_main_blog_library');
add_action('load-upload.php', 'use_main_blog_library');
TheDeadMedic
looks like the only solution at the moment. thanks for this information
choise