🚀 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, images and other attachments uploaded in WordPress are stored in the wp-content/uploads folder under the website's root directory. When a website has a large number of attachments, you might consider separating them 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. Go to 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 URL value after upload; you can enter your own subdomain. Remember to set up DNS resolution and add a virtual host for the domain first.#Website Building# LNMP One-Click Package Adding Virtual Host Graphic and Video Tutorialor#Website Building# Adding Your Own Website in Baota PanelThen, the URL for uploaded attachments will look like the example below.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 previously uploaded content from 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.) You also need to batch replace the image URLs in posts that previously used the wp-content/uploads path with the new image addresses. For replacement methods, refer toBatch Search and Replace Content in WordPress. (If you don't modify them, do not delete the images from the previous wp-content/uploads path, or they won't display.) Therefore, beforebuild a websiteyou 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 instead.

「Naibabiji WordPress Website Building Coaching」 — From selecting a domain and purchasing hosting to installing themes and publishing posts, I「ll guide you through every step, helping you avoid detours and reach your goals directly.

👉 Learn about 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 to Follow