I have a site I'm working on and when it was developed they had all the media uploads go to folder called /assets/ in the root of the WP install. This is being done via: define('UPLOADS', 'assets');
in the wp-config.php file.
This site is is probably 5 years old and has hundreds or more of images there.
What I'm trying to do is remove the uploads definition so that all uploads go in the /wp-content/uploads/ directory where they should have from the beginning. One major reason for doing this is they want to use a plugin called WP Stagecoach, but the plugin won't work with a custom uploads directory.
If I comment out the define('UPLOADS', 'assets');
all the images on the site disappear, even though the image paths are unchanged. And they show up as blank images in the media library.
So...I'm hoping to do one of two things:
- Leave existing images in the assets directory and have newly uploaded images go to the wp-content/uploads directory and have all images appear on both the front-end and the media library. But not sure if this is a possibility.
- Move all the existing images from the assets folder to the wp-content/uploads directory. I know this would most likely require the image URLs to be updated in the DB.
I'm just not sure the best way to approach this. Any advice would be greatly appreciated.
I have a site I'm working on and when it was developed they had all the media uploads go to folder called /assets/ in the root of the WP install. This is being done via: define('UPLOADS', 'assets');
in the wp-config.php file.
This site is is probably 5 years old and has hundreds or more of images there.
What I'm trying to do is remove the uploads definition so that all uploads go in the /wp-content/uploads/ directory where they should have from the beginning. One major reason for doing this is they want to use a plugin called WP Stagecoach, but the plugin won't work with a custom uploads directory.
If I comment out the define('UPLOADS', 'assets');
all the images on the site disappear, even though the image paths are unchanged. And they show up as blank images in the media library.
So...I'm hoping to do one of two things:
- Leave existing images in the assets directory and have newly uploaded images go to the wp-content/uploads directory and have all images appear on both the front-end and the media library. But not sure if this is a possibility.
- Move all the existing images from the assets folder to the wp-content/uploads directory. I know this would most likely require the image URLs to be updated in the DB.
I'm just not sure the best way to approach this. Any advice would be greatly appreciated.
Share Improve this question asked May 18, 2020 at 15:43 Jonathan Ryan PattersonJonathan Ryan Patterson 341 silver badge6 bronze badges 1- Do you have access to htaccess? If so, perhaps you could remove that constant, and set a RewriteRule in htaccess for the old URLs. – vancoder Commented May 18, 2020 at 16:53
2 Answers
Reset to default 1Thanks for the response @jxxe.
So I ended up figuring out how to do what I needed to do. For anyone else who might be needing the same thing, here's what I did.
- Downloaded /assets/ directory via SFTP
- Commented out
define('UPLOADS', 'assets');
in wp-config.php - Uploaded contents of assets to /wp-content/uploads/ via SFTP
Surprisingly, I didn't even have to update anything in the DB for everything to start working correctly. All the images on the front end and the media library showed and the file path updated on its own to use the uploads folder. However, I did use Better Search Replace plugin to globally change all instances of /assets/ to /wp-content/uploads/ in the DB for good measure.
This plugin should help. You will probably have to manually move the files into the WordPress filesystem and sort them into the correct folders.