最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Moving Existing images from custom directory to WP's upload directory

programmeradmin1浏览0评论

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:

  1. 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.
  2. 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:

  1. 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.
  2. 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
Add a comment  | 

2 Answers 2

Reset to default 1

Thanks 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.

  1. Downloaded /assets/ directory via SFTP
  2. Commented out define('UPLOADS', 'assets'); in wp-config.php
  3. 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.

发布评论

评论列表(0)

  1. 暂无评论