Skip to content

Website

How to change Media library upload folder in WordPress?

When it comes to website content, especially when it comes to content such as images, how they are managed can have a huge impact on SEO and overall site performance. The answer to the question of how to change the Media library upload folder can certainly be very helpful.

By default, WordPress saves all media files like images, videos, and PDFs in a folder called “Upload.” You can view the image uploaded from your site using the following path: https://www.nazivsajta.com/wp-content/uploads/naziv-fajla-slike.jpg

If for any reason you want to change the default folder (in this particular case, the Uploads folder) to any other folder that suits you better, here’s a step-by-step guide on how to change the Media library upload folder.

How to change the Media library upload folder?

There are two ways to change the Media Library upload folder to upload images and other media:

 

  1. Creating a new folder in the WordPress installation on cPanel
  2. Creating a new folder on a subdomain outside of your WordPress installation

 

In our text, we will stick to the first way.

Creating a separate folder within the WordPress installation

Ovo će vam pomoći i u dodatnoj sigurnosti premeštanjem svih vaših medija fajlova izvan /wp-content foldera. Ovo su koraci uključeni u ovaj proces:

 

  • Kreiranje novog foldera za upload-ovanje
  • Izmena wp-config.php datoteke
  • Premeštanje postojećih medija fajlova u novi folder
  • Provera i popravljanja broken link-ova
  • Upload-ovanje novog medija fajla i provera njegove dozvole (permission)

 

Za novi WordPress sajt potrebna su samo prva dva koraka, a svi drugi koraci potrebni su za već postojeći sajt koji ima fajlove sa medijskim sadržajem.

Creating a new folder

Assuming you want to store all of your media files in a new directory called “Pictures” for example, you must first create a folder under that name at the root of your WordPress installation. You can create a folder either using FTP or using the “File Manager” option available within the cPanel of your hosting account.

 

Log in to your hosting account and open the “File Manager” option available in the Hosting> cPanel> File Management> File Manager path.

Select the root directory where your WordPress is installed.

 

Select “Web Root (public_html/www)” if you installed WordPress in the root directory or select a subdirectory from the “Document Root for” drop-down menu if you installed WordPress on a subdomain or subdirectory of the main domain.

 

By selecting the New folder option, a window opens in which we create and name a new folder in which we want to store the media content, in our case images. After specifying the name of the new folder and checking if the path on which it will be saved is good, click on Create New Folder.

Now within the WP installation we can see a newly created folder, in our case called Pictures.

Modification of the “wp-config.php” file

The next step is to change the wp-config.php file located in your root directory (usually /public_html). Click on the Edit icon in File Manager.

Add the following lines of code to the wp-config.php file and save the changes.

 

define( ‘UPLOADS’, ”.’ Pictures’ );

 

Be sure to make sure that the quotation marks are spelled correctly (as in the example above), otherwise the changes will not be applied correctly.

Moving existing files to a new folder

When you change the upload folder in wp-config.php all existing media (images) from the site will automatically change the URL in https://www.nazivsajta.com/Pictures/naziv-fajla-slike.jpg. This will result in broken links on posts and pages of the site. You need to move all existing files to a new folder “Picurates” to accommodate broken links. You can do this through the File Manager by dragging and dropping all the image files from the old folder to the new one.

Final checks

The final step is to check if there are still broken links on the site. One way is to use one of the many tools that are offered on the Internet.

From now on, every new file uploaded to the site will be saved in the new folder “Pictures”.

Finally, upload the new image and make sure that the file path is saved in the newly created “Pictures” folder. If you see that the image was not found or a 403 error is being reported, the most likely reason may be the file permission settings of the newly created folder. To check the permissions, connect your FTP software to a server and navigate to the new Pictures folder. Right-click and select the File Permissions option. Select the appropriate permission settings and the numeric value should be 755.

Nadamo se da vam naš tekst objasnio kako promeniti Media library upload folder. Ne brinite, nakon godina iskustva sve ovo će vam biti mačiji kašalj. A do tada pročitajte još edukativnih tekstova na našem blogu.

Made by Nebojša Radovanović – SEO Expert @Digitizer