Support » Networking WordPress » turn off storing uploads by year/month on all sites

  • How do I specify that all sites, existing ones and new ones to be created, do not store uploads in year/month folders? I don’t want to set this once per site. I want one setting or plugin that sets this for all sites.

    thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • You’ll have to do it in the config file, and I haven’t written it up nor tested it yet.

    Thank you Andrea

    I am happy to do some testing myself. Can you share the basic syntax that goes in the config file? What am I setting?

    I tried hunting it down and it escaped me. Probably defining upload_dir.

    You can also define it in sunrise.php (good morning!) if you have it:

    add_filter('upload_dir', 'fix_my_upload_dir');
    
    function fix_my_upload_dir($uploads) {
        $blogdir = [...] find a subdirectory you want to use [...];
    
        $uploads['basedir'] = '/var/www/somedirectory/' . $blogdir;
        $uploads['baseurl'] = 'http://content.bloxxx.net/' . $blogdir;
    
        $uploads['path'] = $uploads['basedir'] . $uploads['subdir'];
        $uploads['url'] = $uploads['baseurl'] . $uploads['subdir'];
    
        return $uploads;
    }

    I wonder how it knows to use separate folders for each site with that…

    @eyecool nag me to write this up! good find with the sunrise.

    What I see is there is an option ‘uploads_use_yearmonth_folders’ that is is set to on in includes/schema.php when a new site is created.

    Is there a way to hook new site creation and turn that option off? Since its on by default when the database entries are created it might have to be turned off after its already been initially saved as on. It appears that’s all that would be necessary.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘turn off storing uploads by year/month on all sites’ is closed to new replies.