WP Manifestindependent plugin directory
manifest / media / unique-media-file-folders

Unique Media File Folders WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Change the default WordPress upload folder structure to a randomly generated one

★ 8stars
88release downloads
≈10active sites
160composer installs
v3.0.1latest · 4 years ago

Install

Download unique-media-file-folders.zip From the v3.0.1 release on GitHub, May 17, 2022

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/creunafi/unique-media-file-folders/releases/download/v3.0.1/unique-media-file-folders.zip

On Packagist as joppuyo/unique-media-file-folders:

composer require joppuyo/unique-media-file-folders
Updates itself. It ships its own updater (Plugin Update Checker), so new versions appear under Dashboard → Updates.

Change the default WordPress upload folder structure to a randomly generated one. Each image and its thumbnails will be given an unique folder with a randomly generated name.

Why?

Because WordPress default media file paths are not very good. You either get year-month folders which may look funny if you are re-using content and is reminiscent of WordPress' blogging engine roots. The other option is to put all files into one folder which does not scale when you start to have a lot of files.

Too many files in a folder can lead to performance issues on filesystems like EXT4. If all your files are in the same folder, you’ll also run into file name conflicts.

How it works

Instead of the following file paths:

https://example.com/wp-content/uploads/2019/01/photo.jpg
https://example.com/wp-content/uploads/2019/01/photo-150x150.jpg
https://example.com/wp-content/uploads/2019/01/photo-300x168.jpg

https://example.com/wp-content/uploads/2019/01/image.png
https://example.com/wp-content/uploads/2019/01/image-150x150.png
https://example.com/wp-content/uploads/2019/01/image-300x168.png

The plugin will generate the following paths:

https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo.jpg
https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo-150x150.jpg
https://example.com/wp-content/uploads/cnk3nae60p6f3e942b4cpvm8q/photo-300x168.jpg

https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image.png
https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image-150x150.png
https://example.com/wp-content/uploads/2xv5r4tnlrcodofcq3ageksmb/image-300x168.png

How to install

  1. Download latest version from the Releases tab
  2. Unzip the plugin into your wp-content/plugins directory
  3. Activate Unique Media File Folders from your Plugins page

Customizing folder depth

By default, folder depth is 1 so every file will be given its own folder. Customize folder depth using umff_folder_depth filter. For example:

add_filter('umff_folder_depth', function() {
    return 4;
});

Will yield the following folder structure:

https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo.jpg
https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo-150x150.jpg
https://example.com/wp-content/uploads/c/n/k/3nae60p6f3e942b4cpvm8q/photo-300x168.jpg

https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image.png
https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image-150x150.png
https://example.com/wp-content/uploads/2/x/v/5r4tnlrcodofcq3ageksmb/image-300x168.png

How are paths generated

For all of your files, first a UUID4 will be generated. It will then be encoded into Base36 which means it will contain characters from a to z and 0 to 9. This is used as the folder name. If folder depth option is greater than 1, first n characters of the UUID are used as subfolders.

Further reading

Structuring WordPress’ upload directory to handle lots of files - Ctrl blog

Releases

6 releases. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
v3.0.1 latest
May 17, 2022 4 years ago
unique-media-file-folders.zip
28
May 17, 2022 4 years ago
unique-media-file-folders.zip
7
Feb 13, 2019 7 years ago
unique-media-file-folders.zip
23
Feb 2, 2019 7 years ago
unique-media-file-folders.zip
11
Feb 2, 2019 7 years ago
unique-media-file-folders.zip
8
Feb 1, 2019 7 years ago
unique-media-file-folders.zip
11

Active-site estimate ≈10 comes from the median of recent superseded releases. Method.

A grade

Security

Unique Media File Folders 3.0.1 · audited by WP Registry

No security issues found.

Audited release
3.0.1
Findings
none
Worst severity
—
Content hash
cc9783033314bc34ec15a1ff…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.