By default, all media files and documents uploaded through WordPress are saved in the /wp-content/uploads directory.
The URLs is a reflection of the WordPress directories.
Before WordPress version 3.5, WordPress provides settings under Media that allow publishers to change the name and location of the folder where WordPress stores all media files such as images, videos, PDFs, etc.
WP-Content which contains your themes, plugin and uploaded images.
WP-Config.php is an important file which contains essential settings about your site structure like your database connection details, your site address, etc.
Once you add this to your WP-Config.php, WordPress will treat the new directory name as your content folder.
Most of the entries in WP-Config file start with a keyword – define. It allows you to define values which can be accessed from your WordPress installation.
To change wp-content/uploads to something customs,
Steps
- Backup your website in case anything goes wrong.
- Access your WordPress files, by using a FTP client or hosting control panel to access your WordPress installation’s files.
- Find the
wp-config.php
file in the root directory of your WordPress installation. Updatewp-config.php
by adding lines of code. - Rename the
wp-content
folder to any name changed just now.
Rename wp-content Folder
Add these codes above
/* That’s all, stop editing! Happy publishing. */
before the ABSPATH variable declaration
// Rename wp-content folder
define('WP_CONTENT_FOLDERNAME', 'media');
// Define new directory path
define('WP_CONTENT_DIR', ABSPATH . WP_CONTENT_FOLDERNAME);
// Define new directory URL
define('WP_CONTENT_URL', 'http://yourdomain.com/' . WP_CONTENT_FOLDERNAME);
To rename the uploads folder, add the line
define( 'UPLOADS', 'wp-content/new_upload_folder_name' );
wp-config.php changes are persistent and should not be overwritten by updates.
There are some plugins and themes that do not follow best practices. They use “wp-content” as the path and URL in their code, instead of defining them dynamically. In such cases, the plugins and themes may not function properly and furthermore will also break links to images that are already attached in your posts and that are stored in wp-content.
So, this modification should be taken with caution and, it is better done when you just starting your website. Otherwise, it could ruin your website entirely, and there will be tons of things you have to fix.