• Hi

    I have been using self hosted wordpress for quite a few years (13+), I have a few hundred images that reside on /wp-content .. not /wp-content/uploads

    These were from old blogging systems that would upload the images there and reference them in the post, before we even had a proper Media Library management.

    I wonder if there is any plugin that can allow me to move all those images inside the wordpress Media Library so I can manage it there, or make the Media Library manage images outside /wp-content/uploads only

    Any advise appreciated

    Null

Viewing 3 replies - 1 through 3 (of 3 total)
  • I can think of two options right now, but there may be other options.

    First option (the hard way):

    Manually download and then re-upload your images via the media library.

    Second option (easy and quick way if you have the pre-requisites and know-how):

    This option requires that you have shell and optionally (s)ftp access to your WP install on the host server, as well as the permissions to install software on the server (if WP CLI is not already available). This will usually be the case if you’re hosted on an unmanaged VPS, cloud instance or dedicated server.

    You’ll move all your images into a new, temporary directory (folder) and then use the “WP-CLI” command-line tool to perform a media import from the temporary directory into your WordPress install’s uploads folder. Then you can optionally use WP-CLI to regenerate the image thumbnails as well.

    This option has made importing hundreds or thousands of images into the media library a breeze.

    Of course, backup your site before getting started.

    If you’re able to give this a go, then just let me know and I can try and help you out.

    Thread Starter NullMind

    (@nullmind)

    Hi Nichlas

    I have root to the server, and can do it, now when I use the CLI media import, does it change the code on the post to point to the new media directory ?

    It also states

    If file is recognized as a URL (for example, with a scheme of http or ftp)

    some of mine the post point to the source as such

    href=”/wp-content/image.jpg

    should I first try to find a way to do a search and replace on the DB and replace all “href=”/wp-content/image.jpg” with “href=”https://domain.com/wp-content/image.jpg” ?

    thanks for the help ??

    Hey NullMind,

    I’ve always used /wp-content/image.jpg for all my images on pages and posts, so there’s never been an issue for me when using WP-CLI. But if an absolute path is specified, then I’m not sure if WP-CLI will change the paths. In that case, you will need to find way to carry out a search-and-replace.

    So, after running a full backup of your site:

    1.) create a temporary directory

    /var/www/example.com/public_html/temporary_folder

    2.) Then move all your images to temporary_folder

    3.) Now run the media import command:

    wp media import /var/www/example.com/public_html/temporary_folder/*

    4.) Optionally run the regenerate thumbnails command:

    wp media regenerate –yes

    5.) Test your website and see that everything is in order and whether or not there things you need to change.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Move old images to Media Library’ is closed to new replies.