How to Change Uploads Path and URL in WordPress
Since WordPress 3.5, the upload_path and upload_url_path configuration option has been removed from Media Settings screen if both is set to their default values (empty of ‘wp-content/uploads’), effectively removing an easy way for user to change and set a custom media upload path.
However, WordPress does still support the custom media upload location, despite the UI to change it has been removed. The default media upload path at ‘wp-content/uploads’ tends to expose the identity of WordPress for webmasters who prefer to obscure the CMS used. In addition, changing the directory name for the media upload path also allows users to assign a more appropriate naming convention, such as images, videos, music, files, docs and so on, depending on the type of content which the websites usually upload.
With the UI gone, there’re a few ways to change the media upload path in WordPress, listed below.
Define Uploads constant in wp-config.php
WordPress supports an Uploads constant which can be configured to set a new custom media upload location. The following line of code can be added into wp-config.php to change the default media upload directory.
define( 'UPLOADS', 'relative/path/to/custom/media/upload/directory' );
Replace the ‘relative/path/to/custom/media/upload/directory’ with the full path to the new directory which the uploads should be stored, relative to the WordPress root directory.
For example:
define( 'UPLOADS', 'wp-content/images' );
Using functions.php to change upload_path value in database settings
Add the following function to the active theme functions.php:
if (get_option('upload_path')=='wp-content/uploads' || get_option('upload_path')==null) {
update_option('upload_path','relative/path/to/custom/media/upload/directory');
}
For example:
if (get_option('upload_path')=='wp-content/uploads' || get_option('upload_path')==null) {
update_option('upload_path','wp-content/images');
}
The media upload path value should be changed instantly once there is a page load on the WordPress website. Once the value has been changed, the user interface for changing the folder which the uploaded files are stored will be made available, allowing users to view and edit the value easily.
Use WordPress plugins to force enable the media upload path and URL setting fields
Upload Url and Path Enabler is a WordPress plugin that enable setting fields to change the media upload path and URL. Once enabled, the Media Settings screen will show the Uploading Files section, with options to set a custom folder to store uploads, and set a custom full URL path to files (if WordPress can’t figured the URL out automatically).
Once a value is set for media upload path, users can disable the plugin, as WordPress will always show the Media Uploads settings UI is the value is not empty or default.
[note color=”#FFCC00″]Note that the option to enable or disable organization of uploads into month- and year-based folders is continue to be available, and it can be changed from Settings -> Media on WordPress administrative backend.[/note]Recent Articles
- How To Download HBO Shows On iPhone, iPad Through Apple TV App
- Windows 10 Insider Preview Build 19025 (20H1) for PC Official Available for Insiders in Fast Ring – Here’s What’s News, Fixes, and Enhancement Changelog
- Kaspersky Total Security 2020 Free Download With License Serial Key
- Steganos Privacy Suite 19 Free Download With Genuine License Key
- Zemana AntiMalware Premium Free Download For Limited Time