Modify the folder structure used to upload media files into years


ClassicPress by default sorts media uploads into year and month subfolders. This is a remnant of the days when WP was primarily a blog and new posts were being made weekly or monthly. Month folders are also created automatically which results in a lot of empty folders.

For many users, the first thing they do on a new site is to uncheck this and put all media files into one big folder. However, this can become unwieldy and cause issues with ftp when files start to number many thousands.

I think a good compromise is to keep the option but make it years only.

Possible implementation

I have started to implement this on my sites using a few lines of code in my utility plugin. I’ve just been testing it and it seems to work fine. There is no issue with older media that is still there in the previously created month/date folders.

add_filter( 'option_uploads_use_yearmonth_folders', '__return_false', 100 );
$year = date( 'Y' );
define( 'UPLOADS', 'wp-content/uploads/' . $year );

It would probably also make sense to modify the date selector dropdown box in the media library. I’m not sure how this works or how hard it would be, but I imagine it picking up both the previous year/month folders (if they exist) and all the images in the year folder, eg

Or if it’s easier, just pick up the years (ie include all images in the year and its subfolders).

Will you be able to help with the implementation?

I can’t help with coding, but I can test it out.

Your petition might be a good compromise, but your code will only work for one year.
I answered a WP forum question on exactly this. The person wanted to know why they could only access the current year’s stuff.
The date selector is an unrelated topic. Those dates are from the database, not the file system.

The date system for images is of no use to me generally and neither would one big folder. I would much prefer to be able to sort them by category.
I find for the business sites that I do, that would have images from the original pages and posts that have been added over several years, finding an image to reuse in a new post is a real pain and sometimes not worth the effort.
There was a plugin I used to use that let you create and name image folders, and move images into these folders.
If the image was already in use, and you moved the image to a new folder it updated the urls in the original posts or pages.


This would be a separate petition.

1 Like

That sounds like a useful plugin. I’d certainly use it.


The plugin is
Media File Manager | By Atsushi Ueda
You can make sub-directories in the upload directory, and move files into them. At the same time, this plugin modifies the URLs/path names in the database. Also an alternative file-selector is added in the editing post/page screen, so you can pick up media files from the subfolders easily.
The version I have is Version 1.2.1

I have just installed it on a CP site and it seems to work with out issues.
I can not find it in wordpress plugins and authors site is no longer online.

Found this on github

Tried installing it on CP site but could not get it to work, (does not crash, just gives a blank screen)