Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_uploads_dir still points towards the subsite folder #83

Open
celinenicolas opened this issue Feb 7, 2021 · 0 comments
Open

wp_uploads_dir still points towards the subsite folder #83

celinenicolas opened this issue Feb 7, 2021 · 0 comments

Comments

@celinenicolas
Copy link

The WP core function wp_uploads_dir still returns the subsite directory paths and not the directory for the main media library as defined in the filter network-media-library/site_id.

This means that instead of returning wp-content/uploads/, it returns wp-content/uploads/sites/2.

The issue is seen when using the Fancy Media module in WP Bakery Page Builder. The image is still displayed, but not resized to the correct dimensions, because it cannot find the file in wp-content/uploads/sites/2.

I found a workaround by adding this filter

add_filter( 'upload_dir', 'multisite_upload_dir' ); 
function multisite_upload_dir( $dirs ) {
    $dirs['baseurl'] = network_site_url( '/wp-content/uploads') ;
    $dirs['basedir'] = ABSPATH . 'wp-content/uploads';
    $dirs['path'] = $dirs['basedir'] . $dirs['subdir'];
    $dirs['url'] = $dirs['baseurl'] . $dirs['subdir'];
    return $dirs;
}

Ideally, we'd want this to use the exact path of the media library we chose in network-media-library/site_id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant