0

For multisite, there is shared (can be accessed from all sites) users and usermeta table, options table. So is there any shared upload directory?

if not, is there a way to reliably remove multisite part (eg. sites/2) from upload directory using upload_dir so that it always return main upload directory?

in _wp_upload_dir it is always NOT the case that it adds sites/2. so we cannot just remove that part. also i am not sure now get_site_option( 'ms_files_rewriting' ) is always return false or not (my wp minimum version requirement is 4.4).

so what should be my approach to get upload directory path without additional part for multisite?

EDIT: i can imaging 2 approaches

  1. use upload_dir filter and return _wp_upload_dir without multisite part (write custom function for that)
  2. save absolute path and url for each file in db (but that will create folders for each sites)

which approaches will be better? i think wp should add a filter so that it can be done easily.

  • 2
    Keep in mind that attachments are stored as posts of type attachment, the media library does not scan or list the contents of the uploads folder directly, as a result every site has its own separate media library. Sharing between sites is a very difficult and non-trivial ask. If you ever got an answer for that, it would be too advanced for most WP developers to follow, with lots of issues and caveats. Be warned, down this road madness lies, and it will never meet your expectations. The closest you can get is an external asset service – Tom J Nowell Jul 2 '18 at 18:11
  • It is not for attachments but for some user files which need to be accessed from all sites for that user. Also it does not need to show in media library. – Shamim Hasan Jul 2 '18 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.