Fix Broken Image Links in WordPress After Import


You’ve just completed a WordPress import or a site migration, and while your text content is all there, your images are not. Instead, you see broken image icons, blank spaces, or old image URLs that point to your previous site. This is an incredibly common and frustrating problem. It’s not just a visual issue; it also impacts your site’s professional appearance and can hurt your search engine optimization (SEO). Manually going through hundreds of posts to re-upload or re-link every single image is not a viable solution. This guide will show you how to fix broken image links in WordPress after an import with a safe and efficient two-part process.

A before and after screenshot showing how to fix broken image links in WordPress.

Understanding the Two Types of Broken Image Links

When an image link breaks after a migration or import, it’s usually for one of two reasons:

  1. The URL is wrong. Your imported content still has image URLs pointing to your old domain. For example, a post might contain an image URL like https://old-site.com/wp-content/uploads/image.jpg, which needs to be updated to https://new-site.com/wp-content/uploads/image.jpg.
  2. The file is missing. The database entry for the image was imported correctly, but the image file itself was not properly moved to your new server’s wp-content/uploads folder. The database knows the image should be there, but the file isn’t.

Most import/export tools don’t handle both of these problems perfectly. This is why you need a specialized approach to fix the links and recover the files.

Phase 1: Fix Broken Image Links with a Search and Replace Tool

The first step is to fix any URLs that are still pointing to your old site. For this, you need a search-and-replace tool that can handle serialized data safely, as a standard database query could break your content. We will use a reliable and well-regarded plugin for this purpose.

Before:

  • You have a post with a broken image link: <img src="https://old-site.com/wp-content/uploads/image.jpg" />.

Step 1: Back Up Your Website

Before you make any changes to your database, you must create a full backup of your website. Use a tool like Duplicator or UpdraftPlus to ensure you can restore your site if anything goes wrong.

Step 2: Install a Search and Replace Plugin

From your WordPress dashboard, go to Plugins > Add New and search for a reputable search-and-replace tool. Install and activate it.

Your Guide to Fix Broken Image Links

  1. Configure the Search: In the plugin’s interface, enter your old and new domain names.
    • Search for: https://old-site.com
    • Replace with: https://new-site.com
  2. Run a Dry Run: Use the “Dry run” feature to see exactly what will be changed before you commit.
  3. Execute the Replacement: If the dry run looks correct, disable the dry run option and run the live replacement. The plugin will now safely update all the image URLs in your content.

After:

  • Your post now has a correct image link: <img src="https://new-site.com/wp-content/uploads/image.jpg" />.

Phase 2: Recover the Missing Image Files

Even after fixing the URLs, some images may still be broken because the files are not on your new server. This is a common issue after migrations where the file transfer failed. This is where a media recovery tool comes in.

Recover Missing Image Files to Fix Broken Image Links

  1. Verify Your Files: First, use an FTP client like FileZilla to check your wp-content/uploads folder. If the images are there but still not showing, proceed to the next step. If they are not there, you must re-upload them.
  2. Install a Media Recovery Plugin: From your WordPress dashboard, search for a media recovery plugin. Install and activate it.
  3. Run a Scan: The plugin will scan your wp-content/uploads folder for images that exist on the server but are not in your WordPress Media Library database.
  4. Recover the Images: The plugin will show you a list of images that need to be recovered. Select the images and click “Recover.” The plugin will then create the necessary database entries, making your images visible again in the Media Library and on your posts.

Troubleshooting: What if the Images Still Don’t Work?

  • Check File Permissions: Your server’s file permissions might be incorrect. Ensure your wp-content folder and its contents have permissions set to 755.
  • Clear All Caches: Your browser, caching plugin (e.g., WP Rocket), and CDN (e.g., Cloudflare) can be showing you an old version of your site. Clear all caches to see the changes.
  • Final Search & Replace: Some plugins use serialized data in specific ways. If you’ve tried everything else, a final, broader search and replace can sometimes catch any remaining broken links.

Conclusion

Broken image links after an import or migration are a common but fixable problem. The key is to address both the database links and the missing files. By using a powerful search-and-replace tool and a media recovery plugin, you can fix broken image links in WordPress in a fraction of the time it would take to do it manually. This two-part solution ensures your site is visually perfect and fully functional, allowing you to focus on your content.

A professional-grade plugin can handle both the URL replacement and file recovery, making the process faster and more reliable. The PRO version often supports bulk recovery and other advanced features.