Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk11 min

How to Fix Broken Image Paths After a WordPress Import

Learn why imported WordPress images break and how to repair stale URLs, missing uploads, and absent thumbnails without corrupting serialized data.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Broken images after a WordPress import usually have one of three causes: the stored URL still points to the old domain or folder, the referenced file never reached the new wp-content/uploads directory, or WordPress is requesting a thumbnail size that does not exist. Diagnose which case you have before changing anything.

Back up the database and files, confirm the new WordPress and Site addresses, then use a serialization-aware URL replacement for stale links. Restore missing attachments separately, regenerate missing derivatives when originals exist, and verify the rendered site—including responsive image variants—after caches are cleared.

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.

Identify what is actually broken

Open a page containing a broken image and inspect its HTML or the browser’s Network panel. Record the complete requested URL, the HTTP response, and whether the URL is for the original file or a resized derivative. A 404 usually means the path or filename does not exist; a 403 or similar response points to permissions or server access; a successful response with an unexpected image can indicate a stale cache or a wrong file at that path.

The URL still names the old location

Imported post content can retain the former domain, a previous subdirectory, a CDN hostname, or an old protocol. For example, content may still request https://old.example/wp-content/uploads/2023/09/photo.jpg after the site moved to https://new.example/. WordPress’s migration guidance notes that existing media links continue to refer to the old folder until they are updated.

#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

The file is absent or unreadable

A database replacement cannot create a file that was not copied. Check the destination filesystem for the exact path under wp-content/uploads, including year/month folders and letter case. Also check that the web server can read the file. If the original was deleted, skipped during transfer, or re-uploaded under a different name, you must restore or re-import the attachment rather than only editing URLs.

Only a resized derivative is missing

WordPress often embeds a generated filename such as photo-300x200.jpg while the original photo.jpg is present. This is a different failure from a missing original. Regenerating registered image sizes can recreate the derivative without editing every post.

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

Responsive markup requests another variant

A page may display correctly at one viewport but fail at another because its srcset candidate is missing. Inspect every requested URL, not just the first image you see. Featured images, custom post types, and media embedded in widgets can have different stored paths from ordinary post content.

Use a triage decision before editing

What you find Likely cause Correct repair
The URL contains the former domain, folder, CDN host, or protocol, and the equivalent file exists on the new site Stale URL stored in content or settings Run a serialized-data-aware search-and-replace, then test the rendered pages
The URL is already canonical, but no corresponding file exists in uploads Upload was not transferred, was deleted, or was renamed Copy the file or import it as an attachment; then update the content that needs it
The original exists, but a name ending in dimensions such as -300x200 returns 404 Missing or stale generated size Regenerate the registered sizes, or replace the attachment if the source file is wrong
The file exists but requests fail with an access response Unreadable file or server rule Correct ownership and permissions or the relevant server rule before changing database URLs
Files work after a change only for some visitors Page, object, or CDN cache still serves old markup Clear the applicable caches and repeat the network check

Back up before touching URLs or attachments

Keep independent copies of the database and the WordPress files, especially the entire uploads directory. Store the copies separately from the live host so a mistaken replacement or failed transfer does not remove your recovery path. An external drive or other separate storage is appropriate for this one-time safety copy.

  1. Export the current database using your host’s backup facility or a command such as wp db export before-image-repair.sql.
  2. Copy the complete WordPress files and wp-content/uploads directory to separate storage. Do not rely on a backup that lives only on the destination server.
  3. Write down the old and new scheme, host, and path, for example https://old.example/blog and https://new.example/. Include any CDN hostname that appears in the broken URL.
  4. Record the tables or content types you intend to change. A narrow first pass is easier to review than an unbounded replacement.

An incorrect search or replacement string can damage database content, so do not skip the backup even if the change appears to be a simple domain swap.

Confirm WordPress’s canonical addresses

In the dashboard, open Settings → General and check both fields:

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.
  • WordPress Address (URL) is where the WordPress core files are installed.
  • Site Address (URL) is the public address visitors use.

When a site moves from a subdirectory to the document root, these values must reflect the new location. Existing media links can still contain the old folder even after the two settings are corrected, which is why a separate content replacement is often required.

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

If you cannot reach the dashboard during the migration, a temporary definition in wp-config.php can establish the new addresses while you repair the database:

define( 'WP_HOME', 'https://new.example' );
define( 'WP_SITEURL', 'https://new.example' );

Use the new values only long enough to perform the planned repair. Remove the temporary constants after the database contains the correct addresses, then save the permalink settings in the dashboard if WordPress asks you to refresh rewrite rules.

Replace old image URLs safely

WP-CLI workflow for SSH access

WP-CLI’s search-replace command understands serialized PHP data, which is important because WordPress options, widgets, and metadata can contain serialized arrays. Start with a dry run:

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' --dry-run

Review the reported tables and counts. For a controlled migration, name the tables you intend to edit and leave the guid column out of the replacement:

wp search-replace 'https://old.example' 'https://new.example' wp_posts wp_postmeta wp_options --skip-columns=guid

The exact table list depends on your installation. A multisite network can use the command’s network mode so each site’s tables are considered; do not use a network-wide operation on a single-site installation by accident. WP-CLI also supports exporting the replacement SQL for review instead of applying it immediately:

wp search-replace 'https://old.example' 'https://new.example' --skip-columns=guid --export=/tmp/url-rewrite.sql

Run the replacement only after checking the dry-run output and the old/new strings character by character. If the old site used a subdirectory, search for the complete old base, such as https://old.example/blog, rather than replacing only the hostname and leaving a stale /blog path behind. If images came from a separate CDN, perform a deliberate replacement for that hostname as well.

Dashboard workflow when SSH is unavailable

Better Search Replace provides a dashboard-based route. Its documented sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
  1. Back up the current database and uploads.
  2. Install the plugin on the destination site.
  3. If the site URL is not yet stable, define the new address temporarily in wp-config.php with WP_HOME and WP_SITEURL.
  4. Enter the old URL as the search value and the new URL as the replacement value, select the intended tables, and run the tool’s preview or dry-run facility if offered by your installed version.
  5. Apply the replacement only after verifying the strings and table selection.
  6. Remove the temporary constants and resave Settings → Permalinks if links still use old rewrite rules.

Do not paste an old URL with a trailing slash in one field and a value without it in the other unless you have intentionally planned for both forms. Check protocol, hostname, port, and subdirectory as separate parts of the string. A replacement that fixes post bodies but misses options or widget metadata can leave menus, featured images, or sidebars broken, so include the tables that actually contain those values.

Why blind SQL replacement is risky

Serialized values include lengths that must match the stored string. Changing a URL with an ordinary SQL REPLACE() can leave invalid length data and break options or widgets. Use WP-CLI or a tool that explicitly handles serialized data, and keep the untouched export until every part of the site has passed verification.

Restore attachments that never arrived

Check the destination before importing

Compare the broken URL’s path with the destination filesystem. Check the month and year directory, filename case, and extension. A file named IMG_1234.JPG is not interchangeable with img_1234.jpg on a case-sensitive server. Confirm that the web server account can read the file and that no access rule blocks the uploads directory.

If the original file is present under another name, do not create a second attachment unnecessarily. Replace the attachment file while preserving its identity, then regenerate sizes. If no usable copy exists, obtain one from the old host or a known backup before changing post content.

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

Import a local file or URL with WP-CLI

wp media import creates a WordPress attachment from a local file or a reachable URL. A local example is:

wp media import /path/to/photo.jpg

After import, check the Media Library for the new attachment and its generated metadata. If the imported file is meant to replace an existing attachment, use the attachment-replacement command rather than leaving posts pointing to a disposable duplicate:

wp media replace <attachment-id> /path/to/photo.jpg

Keep the attachment ID when possible. Existing featured-image assignments and metadata then continue to reference the same media item, while the file and generated sizes are rebuilt from the replacement source.

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.

Use WXR import options when repeating the migration

For a WordPress eXtended RSS (WXR) import, the importer can rewrite links that still point to the previous site:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wp import export.xml --rewrite_urls

If matching files are already in a local uploads directory, provide that directory so the importer can reuse them instead of treating every item as absent:

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

These options address different problems: --rewrite_urls changes imported references, while --source-dir supplies local files for matching attachments. Neither option can recover a file that does not exist in the source directory or at the original URL.

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

Regenerate missing thumbnails and other derivatives

Use regeneration when the original attachment is present and the missing URL follows a registered size pattern. First list the sizes configured by the site:

wp media image-size

Then regenerate the derivatives. To create only sizes that are absent, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wp media regenerate --only-missing

A full regeneration is appropriate when image-size settings changed or several sizes are inconsistent:

wp media regenerate

Regeneration does not repair a wrong domain in post content, and it cannot work without a readable original. Conversely, editing every post by hand is unnecessary when the attachment and the registered size still exist; rebuilding the derivative is the cleaner repair.

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

If the source image itself is damaged or has been replaced, use wp media replace <attachment-id> /path/to/new-file.jpg first, then regenerate. Check available disk space before a large regeneration because WordPress may create several files per original.

Verify the rendered site, not just the database

  1. Open representative posts and pages from different publication dates.
  2. Check custom post types, archive pages, widgets, and navigation areas that may store media separately.
  3. Test featured images and images inserted through the block editor or a page builder.
  4. Resize the browser or use a mobile viewport so every srcset candidate is requested.
  5. In the browser’s Network panel, filter for image requests and confirm that expected responses are successful rather than 404 or access errors.
  6. Clear page caches, object caches, and CDN caches after the replacement or regeneration. Recheck in a private window or an uncached session.
  7. Search the rendered HTML and database for the old hostname or folder after the main repair, then investigate any remaining matches instead of replacing them blindly.

There is no universal success-rate statistic for these repairs. A migration is complete when the files, attachment metadata, stored URLs, generated sizes, and cached output all agree on the new location.

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

Choose the least destructive repair

Situation Preferred method Reason
You have SSH and need a repeatable, reviewable migration WP-CLI search-replace with --dry-run, an explicit table list, and serialized-data handling It provides command-line previews, SQL export, and network-aware operation
You have dashboard access but no SSH Better Search Replace after a database backup It supplies a guided dashboard workflow for replacing old and new URLs
The destination file exists but content names the old host URL replacement The problem is a stale reference, not a missing attachment
The destination file does not exist Copy or import the attachment, then update references as needed A database edit cannot manufacture missing binary data
The original exists but a generated size is absent Thumbnail regeneration It recreates the derivative without editing every post
The source file is wrong or unusable Replace the attachment file while retaining its ID, then regenerate Existing featured-image and metadata relationships remain intact

Common failure patterns and their fixes

Only some old URLs were replaced

Run a read-only search for each old hostname, protocol, and subdirectory. A site can contain both http:// and https://, or both a CDN host and the origin host. Plan separate replacements for genuinely different bases, and review remaining matches before each run.

The home page works but imported posts do not

The home page may use a theme option or a newly uploaded logo, while imported post bodies still contain absolute old URLs. Include wp_posts and relevant metadata in the replacement and test older posts, not only the front page.

The database is fixed but images still 404

Inspect the exact new path on disk. If the file is absent, restore it; if only the derivative is absent, regenerate it. If the file exists, check case, permissions, server rules, and caches before running another database replacement.

Regeneration creates files, but the page requests a different name

The requested size may no longer be registered, or post content may contain a stale hard-coded filename. List registered sizes, compare the requested dimensions with those definitions, and update the content only when the original attachment and size configuration cannot produce the requested file.

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.

A temporary URL constant causes confusing redirects

Make sure WP_HOME and WP_SITEURL use the same intended scheme, host, and path. Once the database is corrected, remove the constants and save permalinks so the permanent settings—not a temporary override—control the site.

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

Final checklist

  • Database export and independent file/uploads backup completed.
  • WordPress Address and Site Address show the canonical destination.
  • Old domain, folder, CDN, and protocol forms identified.
  • Search-and-replace preview reviewed before applying changes.
  • Serialized data handled by WP-CLI or a serialization-aware dashboard tool.
  • Missing originals restored or imported as attachments.
  • Registered derivatives regenerated when originals exist.
  • Featured images, custom post types, widgets, and responsive srcset URLs tested.
  • Page and CDN caches cleared, followed by a second network-panel check.

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 *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.