brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: the UPLOADS constant moves the WordPress media folder out of wp-content

WordPress
~/tips/tip-wordpress-uploads-constant-folder

define( 'UPLOADS', 'media' );

Puts new uploads in a folder of your choice, relative to the WordPress root.

Media lives in wp-content/uploads by default. One line in wp-config.php puts it somewhere else, and the URLs follow.

define( 'UPLOADS', 'media' );

With this, new uploads go to media/2026/11/ next to wp-admin, and their URLs become https://example.com/media/2026/11/photo.jpg. The path is always relative to the WordPress root folder, ABSPATH. The docs say it plainly: it cannot be absolute, so no leading slash.

Why I’d use it: shorter, cleaner image URLs, or a separate mount for media in a container setup, so the uploads can live on another volume than the code. Put the line above the “stop editing” comment, like any other constant.

It works for new uploads only. Files that are already there keep their old path in the attachment data, so they stay in wp-content/uploads and keep working. To really move them you’d copy the files and then run a search and replace on the URLs, which is a bigger job than the constant suggests. Test that on a copy.

The web server user must be able to write to the new folder. And on multisite with the old ms-files rewriting turned on, WordPress mostly ignores this constant, so check that case first.

Further reading: wp-config: Moving uploads folder, wp_upload_dir()

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link