Created
January 27, 2014 20:20
-
-
Save azanebrain/fa912c4b20415e7bc728 to your computer and use it in GitHub Desktop.
Set a unique upload path for each site on a multisite network (MU Plugin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('upload_dir', 'mu_media_upload_dir'); | |
function mu_media_upload_dir($upload) { | |
$site_title=str_replace( ' ' , '_' , get_bloginfo('name','raw') ); | |
$upload['path'] = ABSPATH . '/shared/' . $site_title; | |
switch_to_blog(1); | |
$upload['url'] = site_url() . '/shared/' . $site_title; | |
restore_current_blog(); | |
$upload['subdir'] = ""; | |
$upload['basedir'] = $upload['path']; | |
$upload['baseurl'] = $upload['url']; | |
return $upload; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an MU Plugin that automatically saves media uploads to /shared/<your site's name>
It replaces spaces in the name with an underscore