Hi @lveale, moving the uploads folder in multisite is more complex than in regular single site WordPress. Take a look at this part of the docs around this:
https://wordpress.org/support/article/multisite-network-administration/#uploaded-file-path
Thread Starter
lveale
(@lveale)
Thanks @mmaattiiaass sounds like this could be problematic…
So my next question is, is it possible to mask the image urls in some way so that it doesn’t show the parts I want to remove on the front end in the address bar or when hovering over a link?
Thanks!
It’s been a while since I set it up, so I may be forgetting some critical element, and I have my network configured so put all uploads in the same folder, regardless of site (and then have them further sorted by type and some other criteria) so it may not translate to your situation exactly, but I don’t recall replacing the wp-content/uploads/sites part of the upload path being all that difficult.
I haven’t tested this exactly, but try something like:
add_action('init', 'new_upload_filters');
function new_upload_filters(){
if( !is_main_site() ) add_filter('upload_dir', 'new_upload_dir');
}
function new_upload_dir( $dirs ) { //set base upload folder
$site = get_current_blog_id();
$dirs['baseurl'] = network_site_url( '/resources' );
$dirs['basedir'] = ABSPATH . 'resources';
$dirs['path'] = $dirs['basedir'].$site;
$dirs['url'] = $dirs['baseurl'].$site;
return $dirs;
}
hope that helps!
@lsell – Where did you put this code? Theme functions?
@yourbusybee I did have it in theme functions originally, but ended up moving it into a plugin because a couple of my subsites use different themes and I didn’t want to have redundant code to maintain. Either way could work, depending on your setup/needs.