1

Until now I have used default WordPress directory structure, however since I started using GIT, I plan to setup WordPress as a submodule and also change the paths of upload folder.

Since the path for existing images is already set in the database, is there a way to change them automatically?

  • You could use Database Search and Replace Script in PHP that works like a charm in Wordpress. Search "wp-content/uploads" and replace with "your-new-path". – cybmeta Mar 22 '14 at 10:11
  • Hi, I used this script earlier, now just used WP Migrate Pro plugin. It has search and replace along with export so that did the trick. – Harish Chouhan Mar 22 '14 at 12:31
7

if you need to change default media upload location,you need to edit the wp-config.php file located in the root directory of your WordPress installation. If you want upload directory to be wp-content/files then you will need to place the following code in wp-config.php

define( 'UPLOADS', 'wp-content/'.'files' ); 

If you want the upload directory to be outside wp-content, like http://www.example.com/files/ then you need to set upload path in wp-config.php like this:

define( 'UPLOADS', ''.'files' ); 

For exstining images:-

Copy all the exstining images of uploads folder to new folder which has set in the wp-config.php file.

The above information is only to Change the Default Media Upload Location.

  • Thanks Dipali. I have already setup the new path similar to the code you shared. My question is about changing the path of images that were uploaded prior to this change. Since WordPress hardcodes the image paths directly in the database. For now I have managed to use WP Migrate Pro plugin to do the changes to existing images, however just wanted to know if there was any other way. – Harish Chouhan Mar 22 '14 at 9:26
  • 1
    Well, that answer doesn't work if you're not having wp in your root directory, but in a subfolder. WP always puts ABSPATH in front of the value of UPLOADS – Volker E. Feb 22 '15 at 3:52
  • Would wordpress still create sub folders by year if default upload folder is changed? – Ambrish Pathak Feb 1 '18 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.