By default, attachments such as images uploaded to WordPress are stored in the wp-content/uploads folder under the website root directory. When a website has a particularly large number of attachments, one might consider separating them out for a CDN or using another domain for distribution. Below is a guide on how to customize the upload folder in WordPress 5.2.
Method 1: Modify the wp-config.php file
Insert the following code snippet into the wp-config.php file to customize the upload folder.
define('UPLOADS','file');Change 'file' to your desired folder name. After setting this, the URL for uploaded images will look like the example below.

Method 2: Modify WordPress configuration information
Actually, WordPress has many default configuration options, but they are hidden to simplify operations. Open your admin address /wp-admin/options.php, for example,
https://blog.naibabiji.com/wp-admin/options.php
You will discover (oh my, what is all this? WordPress is too complex for me) many, many English settings options. Then, search for 'upload' to see the following two options.

'upload_path' is the value for the upload path, for example, enter 'file'. 'upload_url_path' is the value for the URL after upload; you can enter your own subdomain. Remember to first set up DNS resolution and add a virtual host for the domain.
#Website Building# LNMP One-Click Package Adding Virtual Host Graphic and Video Tutorialor
#建站# Add your own website in Baota PanelThen, the URL for uploaded attachments will look like the following.

Naiba's Tip: These settings take effect immediately, and the URLs for all attachments in the media library will change to the new ones. You need to move all content previously uploaded to the wp-content/uploads folder to the new folder. (If you don't move them, thumbnails for images in the media library won't display.) Then, you also need to batch change the image addresses in articles that previously used the wp-content/uploads path to the new image addresses. For the replacement method, please refer to
Batch Search and Replace Content in WordPress. (If you don't make these changes, do not delete the images from the previous wp-content/uploads location, or they won't display.) Therefore, before
Build a Website, you should plan your website to avoid the hassle of modifying these things midway.
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.