• I moved my WordPress media files to a new location. It no longer exists at the default location (wp-content/uploads). It now exists at ‘wp-content/uploads/private’. I had to do this for a plugin.

    Now my media files are missing from my online WordPress media library (https://imgbox.com/EdXwg6lk), and the media section of the WordPress app (https://imgbox.com/JoCtlcc1). I expected this might happen, but I don’t know how to fix this without moving them back.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    Add this line to wp-config.php:
    define( 'UPLOADS', 'wp-content/uploads/private' );

    Ref: https://codex.www.ads-software.com/Editing_wp-config.php#Moving_uploads_folder

    Thread Starter wooferdog

    (@wooferdog)

    Hi @bcworkz, do you know if the wp-config file is independent of the database?

    Thanks for your help! ??

    Thread Starter wooferdog

    (@wooferdog)

    Also, do I replace or add to?

    current:

    /** Absolute path to the WordPress directory. */
    if ( !defined(‘ABSPATH’) )
    define(‘ABSPATH’, dirname(__FILE__) . ‘/’);

    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . ‘wp-settings.php’);

    Moderator bcworkz

    (@bcworkz)

    Add to, above the code that you posted.

    The file is independent of the DB in that it is not required in order to access the DB by other means. However, it contains the DB credentials that WP needs to access the DB. Some hosts have the DB on a completely different server than the server that contains wp-config.php.

    Thread Starter wooferdog

    (@wooferdog)

    Hmm… well I added it, but nothing appears to have changed. I added the define before, no change. So I added it in-between (as suggested by the WP link you posted), but nothing happened there either?

    Moderator bcworkz

    (@bcworkz)

    First try uploading a new image file, at least that part should work.

    The remaining problem is there are likely references in the DB that still refer to the old location even though you’ve defined a new location and all the actual files reside in the new location. Most commonly these are references in post content to media files where the entire file path is part of post content. In other references, the path is determined by defined constants and the paths are updated automatically. Not so for post content and similar references.

    To correct this, use the better search and replace plugin. Assuming your uploads are sorted into year folders, search for occurrences of “/wp-content/uploads/20” and replace with “/wp-content/uploads/private/20”. Including “/20” avoids adding a second private/ into URLs that are already correct.

    If you don’t have year folders, you can let the double private/ path elements happen, then go back and search for the double occurrences and replace with just the single.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Moved media folder to new location, now files don’t show up in WordPress’ is closed to new replies.