I thought adding the media files to the uploads/ folder over FTP would solve the problem, since I believed I had copied the original database to create the draft site. The images would exist in the right place, and we could update the paths to ensure the files were accessible using the draft website path instead of the original site’s path.
How to import media files uploaded over FTP
We had already changed the content of the site so it was no longer an exact copy of the original. Since we didn’t want to redo any work that had already been done, that precluded many other possible solutions. We wanted to preserve the existing pages and posts in the database, which are stored in the same table as the media attachments, so a solution that would import by overwriting the existing database wouldn’t work for this situation.
Fortunately, I stumbled across a little gem called Media Sync.
The Media Sync plugin scans the uploads/ folder on the server, and imports missing images into the database.
Before you begin, be sure to back up your site using Updraft Plus or your chosen backup solution.
Once you add and activate the plugin, click on Media Sync:
Testing after importing:
- Check your media library to be sure you see the images.
- If the images are already in use on the site, make sure they still show up, and verify they use the correct paths.