turn off storing uploads by year/month on all sites (8 posts)

  1. stvwlf
    Posted 5 years ago #

    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

  2. You'll have to do it in the config file, and I haven't written it up nor tested it yet.

  3. stvwlf
    Posted 5 years ago #

    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?

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

  5. Eyecool
    Posted 5 years ago #

    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;
  6. I wonder how it knows to use separate folders for each site with that...

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

  8. stvwlf
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic