How to Customize Media Upload Directory in WordPress

Get real time updates directly on you device, subscribe now.

Despite improvements in the Media Manager of WordPress, one thing has not changed:  how WordPress stores media  (eg files, images, videos and audio)   on the server.

Currently, WordPress organizes files in date-based folders, unless we opt out of this via  Settings> Media, in which case all uploaded media files will not be categorized into subfolders. So far, WordPress does not offer many options to customize this specific area.

If you are not cool with this and want to adjust the path structure from where these files are stored, for example saving to a folder with a name that matches the permalink or changing the name ‘uploads’ to something else, this is the quick tip to follow.

With the help of a few plug-ins, we can now make our website more personal and organize it easily with customized file structures.

Change the default “uploads” folder

WordPress saves the uploaded files by default in the wp-content / uploads folder. With WordPress, we can adjust the destination of the upload folders. A good reason to change this default setting is to make your website look less like WordPress-y.

Instead of wp-content/upload, let’s upload the files to a folder named files. First, we have to create the folder.

Now let’s see how WordPress uploads our files in that folder. Open the WordPress wp-config.php file and add the following code after the declarationrequire_once(ABSPATH.'wp-settings.php');.

New uploaded files must now be saved in the ” files” folder, as shown below.

This option was actually available via the  Settings> Media Editor back in version 3.0 screen. WordPress has replaced this in the above function in version 3.5.

If you are too scared to mess up the  wp-config.php, you can install this plug-in called  Upload URL and Path Enabler from Gregory Viguier, which will return the option to the  Setting> Media page. Note that this plug-in has not been updated for over 3 years, but the plug-in is still working well in the latest version of WordPress because there is not much change in this area in WordPress.

After it is installed, you will find 2 input fields, as shown below:

These 2 new options will be useful, for example, if you want to deliver your files via a subdomain. Assuming you created a subdomain (from your host control panel), there should now be a new folder that links to the subdomain. Set the folder name in the ‘Save Uploads to this Folder’ field and the subdomain in the ‘Full URL to files’ field.

Your file should now be delivered via the subdomain.

Keep in mind that if you choose the subdomain as the example above, you might have to refer DNS to the subdomain according to your site’s IP address

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More