October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Fix Broken Image Paths After a WordPress Import

A practical, serialization-safe workflow for fixing old image URLs, restoring missing attachments, regenerating thumbnails, and verifying a WordPress import.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Repair broken images in this order: determine whether the URL is wrong, the file is missing, or only a resized derivative is absent; back up the database and uploads; correct the site URLs with a serialization-aware tool; re-import files that never arrived; regenerate thumbnails; then test rendered pages and responsive image variants.

What a broken image path actually means

An imported WordPress site can show a missing image icon even when the page itself loads normally. The image reference may still contain the old domain, an old subdirectory, a former CDN hostname, or the wrong protocol. The URL may be correct while the file was never copied into wp-content/uploads, was deleted, was re-uploaded under a different name, or cannot be read by the web server. A third case is a missing derivative: the original exists, but a generated filename such as image-300x200.jpg does not.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

These are different failures. A database replacement cannot create a file that is absent, and regenerating thumbnails cannot repair a URL that still points to the old domain. Diagnose the class before changing anything.

Old location embedded in content

WordPress stores image URLs in post content and in other database fields. After a move, those values can continue to point to the previous domain or folder. The WordPress Advanced Administration Handbook cautions that existing media links refer to the old folder and must be updated when the location changes. This is the usual cause when every image from an imported site points to the former hostname or a path such as /old-site/wp-content/uploads/.

#1 Best Overall
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
  • Slim durable design to help take your important files with you
  • Vast capacities up to 6TB[1] to store your photos, videos, music, important documents and more
  • Back up smarter with included device management software[2] with defense against ransomware
  • Help secure your important files with password protection and hardware encryption
  • 3-year limited warranty

Correct URL, missing destination file

Open one failing URL directly in a browser and compare its path with the destination server. If the URL uses the new domain and the expected file is not present under wp-content/uploads, URL replacement is not the remedy. Restore the uploads directory or import the missing attachment.

Only a resized derivative is missing

When the original image opens but a thumbnail or responsive size returns 404, the import may have omitted generated sizes. WordPress can recreate registered derivatives from the original attachment. This is common after a migration that copied originals but not every generated file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Back up before touching URLs or media

Make two independent copies before editing the database: export the database and copy the WordPress files, including wp-content/uploads, to separate storage. Keep a copy on an external drive or another system so a mistaken replacement does not leave you with only the damaged database. The WordPress handbook specifically recommends downloading the main WordPress files before changing configuration and URLs.

  • Record the current WordPress Address (URL) and Site Address (URL).
  • Save the database export with a date and identify the destination site.
  • Copy the complete uploads tree, not just the files visible in the Media Library.
  • Keep the original backup untouched until representative pages, featured images, and responsive variants pass verification.

A wrong search or replacement string can damage the database. The Better Search Replace documentation gives the same warning: “Entering a wrong search or replace string could damage your database.” A backup is therefore a prerequisite, not an optional precaution.

Confirm the site’s canonical URLs

In the WordPress dashboard, open Settings → General. Verify both fields:

  • WordPress Address (URL) — where the WordPress core files are installed.
  • Site Address (URL) — the public address visitors use.

Check the protocol (http versus https), hostname, and any subdirectory. A site installed in a folder can legitimately have different values, but an accidental old folder or hostname will keep producing bad media links. Existing links in posts may still contain the previous location even after these settings are corrected; changing the settings establishes the canonical values but does not rewrite every stored reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
  • Slim durable design to help take your important files with you
  • Back up smarter with included device management software[2] with defense against ransomware
  • Help secure your important files with password protection and hardware encryption
  • 3-year limited warranty

Use the failure class to choose the repair

What you observe What to check Appropriate repair
Image URL contains the old domain, folder, CDN host, or protocol Inspect the rendered HTML and the stored post content Serialization-aware URL replacement
URL uses the new site, but the original file is absent from wp-content/uploads Check the destination filesystem and the attachment record Restore the uploads copy or re-import the attachment
Original opens, but -300x200 or another registered size returns 404 Compare the requested derivative with files beside the original Regenerate the registered image sizes
Only imported posts or a particular content type is affected Inspect that content type’s fields and attachment references Target the relevant tables or re-import the affected media

Repair old URLs safely with WP-CLI

WP-CLI is the most controllable route when you have SSH access. Its search-replace command understands serialized data, which matters because WordPress stores arrays and objects with embedded string lengths. A blind SQL REPLACE() can leave those lengths incorrect and corrupt options, widgets, or other settings.

1. Test the exact old and new strings

From the WordPress installation directory, preview the replacement without writing changes:

wp search-replace 'https://old.example' 'https://new.example' --dry-run

Use the complete value that is actually stored. If the failure is an old subdirectory, include that path; if it is a protocol-only change, use the precise protocol and hostname combination. Do not replace a short fragment that could match unrelated text.

2. Export and limit the scope

Export a fresh copy immediately before the live replacement, and target the intended tables rather than changing every table by habit. WP-CLI documents an export option and modes for multisite installations. On a single site, a representative command is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wp search-replace 'https://old.example' 'https://new.example' --export=before-replace.sql --skip-columns=guid

The guid column is commonly skipped in documented examples because a post’s GUID is an identifier, not a canonical display URL. Decide table scope deliberately: post content, post metadata, options, and any custom tables used by the imported site may hold media references. For multisite, run the network-aware mode or the correct site URL context instead of applying a single-site replacement to the whole network.

3. Run the serialization-aware replacement

After reviewing the dry-run counts and the export, execute the same search and replacement without --dry-run. Keep the old and new strings visible while you run the command so a reversed argument cannot silently rewrite the site in the wrong direction. WP-CLI updates serialized values while preserving their structure.

Rank #3
ModusTech Facet 500GB External Hard Drive Portable USB-C/USB 3.1 Plug & Play Ultra- Slim HDD Hard Drive for Backup, Gaming, PC, Mac, Laptop, PS4, Xbox, Smart TV (Black)
  • High-capacity external hard drive with up to 2TB of storage The ModusTech Facet portable external hard drive gives you dependable HDD storage in a slim 2.5-inch design. Multiple capacities available up to 2TB — back up photos, videos, music, documents, and game libraries with room to grow. A trusted external storage solution for everyday backup, media archives, and creative work.
  • USB-C and USB 3.1 connectivity with included 2-in-1 cable The Facet ships with a USB-C to USB-C cable and tethered USB-A adapter, so this external hard drive connects to modern laptops, USB-C iPhones, tablets, and older USB-A computers without buying an extra cable. USB 3.1 Gen 1 (5Gbps) interface delivers real-world transfer speeds up to 100MB/s — fast enough to back up 50GB of files in about 8 minutes.
  • Plug-and-play external hard drive for PC, Mac, and laptops Preformatted in exFAT and ready to use the moment you plug it in. The Facet works out of the box with Windows PCs, macOS Macs, MacBooks, Chromebooks, and laptops — no drivers, no software, no setup required. A true plug-and-play external hard drive built for everyday use across every major operating system.
  • External hard drive for PS4, Xbox One, and Smart TV gaming The Facet is compatible with PlayStation 4, Xbox One, and Smart TVs with USB support. PS4 and Xbox One games run directly from the drive — plug it in, format through the console, and add to your storage. Also works with Smart TVs that support USB recording or external media playback.
  • Slim, shock-resistant portable external hard drive — 160g At 2.5 inches and just 160g, this portable external hard drive is bus-powered through a single USB-C cable — no separate power adapter, no extra cables. Slim enough for a laptop bag, jacket pocket, or camera bag, with a shockresistant casing and faceted diamond-texture top panel that resists fingerprints and everyday wear. Backed by a 1-year limited warranty from ModusTech, a consumer electronics brand specializing in external storage.

4. Clear caches and inspect stored content

Open a few affected posts in the editor or query their rendered HTML to confirm that the new host and path are present. Clear page-cache and CDN layers only after the database change; otherwise a cached page can make a successful replacement appear to have failed.

Run the replacement from the dashboard when SSH is unavailable

Better Search Replace provides a dashboard workflow for operators who cannot use WP-CLI. Follow the documented order:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Back up the current database and retain the uploads copy.
  2. Install the tool on the new host.
  3. Temporarily define the new site URL in wp-config.php with the appropriate WP_HOME and WP_SITEURL constants if the dashboard is not yet reachable.
  4. Open the tool, enter the old URL as the search value and the new URL as the replacement, and run its dry-run or preview facility before writing changes.
  5. Run the serialized-data-aware replacement against the tables that contain the imported content.
  6. Remove the temporary constants once the database values are correct.
  7. Open Settings → Permalinks and resave the existing structure if rewritten links still behave incorrectly.

Do not use a generic SQL text replacement in place of a serialization-aware tool. Serialized values contain lengths that must be recalculated when a URL changes.

Restore attachments that never arrived

If a URL now points to the correct domain but the file is absent, first restore the matching uploads directory from your backup. When the original is available elsewhere but not in the destination Media Library, WP-CLI’s media import command can create an attachment from a local file or a URL. Confirm the file’s name and location before importing so you do not create a second attachment for an image that already exists.

wp media import /path/to/image.jpg

The import creates an attachment record for the file. You may then need to update the content that referenced the old attachment, especially if the imported site used custom fields or a custom post type rather than ordinary post content.

Use WXR import options for a repeatable migration

When the source site was exported as WordPress eXtended RSS (WXR), the importer has two options that address common media failures:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Seagate One Touch 24TB External Hard Drive Desktop HDD - USB-C Compatible with Most Windows and macOS, Rescue Recovery (STNB24000400)
  • No wall warts: Work freely with its bus-powered USB-C. No wall outlet required.
  • Big on space: High-capacity storage to store all your files in one place.
  • Reliable backup: Safeguard assignments, projects, or sensitive files with trusted performance.
  • Fuss-free, clutter-free: One port, one cord, quick connect.
  • Peace-of-mind: Comes with two-year limited warranty and Rescue Data Recovery Services.
  • --rewrite_urls changes imported links that point to the previous site so they point to the site receiving the import.
  • --source-dir lets the importer reuse matching files already present in a local uploads directory.

A command using both options is:

wp import export.xml --rewrite_urls --source-dir=/path/to/wp-content/uploads

The import documentation describes --rewrite_urls as changing imported URLs that currently link to the previous site so they link to the current site. These options help during the import itself; they do not repair files that are missing from both the source archive and the local directory.

Regenerate missing thumbnails and responsive sizes

Do not edit every post manually when the original attachment exists. WordPress registers image sizes and stores the generated filenames beside the original. Use the media command set to list the registered sizes, regenerate derivatives, and, where necessary, replace an attachment file while retaining its attachment identity. The exact registered sizes depend on the active theme and plugins, so inspect the current site rather than assuming that a size from the old site still exists.

List the sizes the site expects

Compare the requested filename in the 404 response with the sizes currently registered by WordPress. A derivative can be missing because the destination theme does not register the old size, because generation failed, or because only the original was copied.

Regenerate from the original

Run thumbnail regeneration after confirming that the original file is present and readable. Regeneration can recreate the registered derivatives, including the dimensions used by featured images and responsive srcset markup. It cannot recreate a source image that was never transferred, and it will not restore a custom crop that is no longer registered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Replace a damaged source without changing its identity

If the attachment record is correct but the source file is corrupt or was re-uploaded under a different filename, use media tooling that replaces the attachment file while preserving its attachment identity. Retaining the identity avoids rewriting every post that references the attachment. Verify the command’s syntax on the installed WP-CLI version before running it, then regenerate derivatives again.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the rendered site, not just the database

A successful command is not proof that readers can see every image. Test the site as a visitor and inspect network responses.

Best Value
WD 5TB My Passport Ultra for Mac Silver, Portable External Hard Drive, backup software with defense against ransomware, and password protection, USB-C and USB 3.1 - WDBPMV0050BSL-WESN
  • USB-C and USB 3.1 compatible.Specific uses: Business, personal
  • Innovative style with refined metal cover
  • Password protection with 256-bit AES hardware encryption
  • Formatted for Mac
  1. Open representative posts and pages from before and after the import.
  2. Include custom post types, archive pages, and templates that use featured images.
  3. Open the Media Library and a sample attachment page.
  4. Inspect browser developer tools for image requests returning 404, redirect loops, or mixed-content errors.
  5. Check the srcset and sizes attributes so responsive variants use the new host and existing files.
  6. Test images embedded in post content as well as CSS background images and theme thumbnails.
  7. Clear page and CDN caches, repeat the checks, and test from a separate browser or an unauthenticated window.

There is no universal success-rate statistic for this repair process. The reliable test is a crawl of the actual templates and representative content after caches have been cleared.

Troubleshoot by symptom

Every image still points to the old domain

Recheck WordPress Address and Site Address, then inspect the exact stored URL. Run a dry-run search for the old hostname, including protocol and subdirectory, before performing the serialized replacement. If no rows are found, the URL may be in a custom table, a theme setting, or a cached page rather than ordinary post content.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The new URL returns 404 for every image

Compare one URL with the filesystem. If the corresponding file is not under the destination uploads path, restore or import it; repeating a URL replacement will not create it. If the file exists, check that the web server can read it and that the uploads path is served by the current host.

Originals work but thumbnails do not

Identify the missing suffix, compare it with the registered image sizes, and regenerate derivatives from the original. If the old size is no longer registered, the site may need its former theme or plugin setting restored before regeneration can produce the expected filename.

Images work in posts but not in featured cards

Featured-image templates often request a different registered size. Test the archive and card template separately, inspect its requested filename, and regenerate that size. If the template stores a direct URL in custom metadata, include the relevant table in a controlled replacement rather than editing each post.

The dashboard is inaccessible after the move

Use the temporary WP_HOME and WP_SITEURL definitions only long enough to reach the site and correct the database values. Remove them after the replacement; leaving temporary constants can make later URL changes confusing and can override dashboard settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prevent the next import from breaking media

  • Copy the complete uploads directory before importing the database or WXR file.
  • Record the source and destination domain, protocol, and installation subdirectory.
  • Use WXR URL rewriting during import when the source URLs are changing.
  • Keep a local source directory available when the importer can reuse matching attachments.
  • Use serialized-data-aware replacement for post content, options, metadata, and custom tables.
  • Regenerate registered sizes after changing themes or image-size settings.
  • Include featured images, custom post types, and responsive variants in the post-migration check.

The durable fix is a matched database-and-files migration: URLs must identify the new site, and every referenced original and derivative must exist at that location.

Quick Recap

Bestseller No. 1
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
WD 2TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBYVG0020BBK-WESN
Slim durable design to help take your important files with you; Help secure your important files with password protection and hardware encryption
$132.10
SaleBestseller No. 2
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
WD 5TB My Passport, Portable External Hard Drive, Black, backup software with defense against ransomware, and password protection, USB 3.1/USB 3.0 compatible - WDBPKJ0050BBK-WESN
Slim durable design to help take your important files with you; Help secure your important files with password protection and hardware encryption
$214.90
Bestseller No. 4
Seagate One Touch 24TB External Hard Drive Desktop HDD - USB-C Compatible with Most Windows and macOS, Rescue Recovery (STNB24000400)
Seagate One Touch 24TB External Hard Drive Desktop HDD - USB-C Compatible with Most Windows and macOS, Rescue Recovery (STNB24000400)
No wall warts: Work freely with its bus-powered USB-C. No wall outlet required.; Big on space: High-capacity storage to store all your files in one place.
Bestseller No. 5

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.