Simple WP filter to modify media upload directory

Benefits of this: 

  • Faster Identification of Assets: By default, WordPress creates folders based on the id of the site. Changing this so folders are created based on the domain of the site makes asset folders easier to organize and identify.
  • Security: Altering WordPress defaults can thwart attacks from automated hacking scripts that just target certain default directories.

Multisite Example Code: 

If you’re changing some existing sites to a new structure you may have to do two things:

SQL Find and Replace Code:

Example on WP Posts:


If you’re on certain shared hosting environments you may run into trouble getting directories that aren’t subs of the “/sites/” folder to work properly because of permissions imposed and enforced by your host but it is possible and it’s nice if all your files are store more at instead of the longer default directory from WordPress.