Wordpress 3 Multisite with the same Mediatibrary

i created Worpress 3 Multisite with 5 sub-blogs. Is it possible to share the same media library on these blogs?

i changed upload_pathin wp_1_optionsand wp_2_options, for example, as well as in my backend in the "Super administrators" menu, but it has no effect.

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

any ideas? thank!

+3
source share
3 answers

One way is to connect to the download events of all media admins files and go to the main blog using switch_to_blog(1).

, - , .

, :

  • .
  • admin
  • admin
  • .

- , , , .

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');
+4

, , , -, , ...

, , , , , -.

Shiba , - .

, , , . , - .

+1

, WP3.7.1 ( )

, :

add_filter('upload_dir', 'ms_global_upload_dir');

function ms_global_upload_dir($uploads)
{
    $ms_dir = '/sites/' . get_current_blog_id();

    $uploads['path']    = str_replace($ms_dir, "", $uploads['path']);
    $uploads['url']     = str_replace($ms_dir, "", $uploads['url']);
    $uploads['basedir'] = str_replace($ms_dir, "", $uploads['basedir']);
    $uploads['baseurl'] = str_replace($ms_dir, "", $uploads['baseurl']);

    return $uploads;
}

: " URL-" , , $uploads, .

, WP , wp_upload_dir() wp-includes/functions.php : $uploads = apply_filters( 'upload_dir' ... , .

, ...

In addition, I spent almost two days creating a solution for replicating / deleting downloadable media in each blog using add_attachment and add_attachment using hook, adding the necessary post and postmeta entries to the corresponding database tables. / delete media in any of the blogs that will be displayed / deleted from the library of all blogs. If you are interested, I can share it ...

Greetings

0
source

Source: https://habr.com/ru/post/1753689/


All Articles