🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

WordPress Custom Attachment Upload Folder and URL

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.Wordpress上传目录

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.Wordpress上传目录'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.Wordpress上传目录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 toBatch 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, beforeBuild a Website, you should plan your website to avoid the hassle of modifying these things midway.

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step.

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the Website Building Coaching Service
🔒

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.

×
二维码

Scan QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: