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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Broken images after a WordPress import usually come from one of three separate problems: the database still contains the old domain or folder, the image file was never copied to the new server, or WordPress is requesting a resized derivative that no longer exists. Fix them in that order. Back up the database and uploads first, verify the site URLs, use a serialization-aware URL replacement when files are present, re-import missing attachments when they are not, and regenerate thumbnails when only derivative sizes are missing.

Why images break after a WordPress import

An import moves database records and, depending on the method used, may also move media files. Image references can remain embedded in post content, featured-image metadata, widgets, custom fields, CSS, or responsive srcset attributes. A page can therefore contain a perfectly valid attachment record while its rendered URL still points somewhere that no longer exists.

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

The URL still names the old domain or folder

Moving from https://old.example to https://new.example, changing from a subdirectory to the web root, or changing a CDN hostname leaves old links in stored content unless they are rewritten. The WordPress Advanced Administration Handbook warns that existing media links refer to the old folder after a move and must be updated.

The file is absent from the destination

A database replacement changes text only. It cannot recreate an image that was not copied, was deleted, was re-uploaded under a different filename, or cannot be read because of filesystem ownership or permissions. Check the actual uploads directory separately from the database.

#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

Only a resized derivative is missing

WordPress may request a filename such as image-300x200.jpg even though the original image.jpg exists. This happens when generated thumbnails were not transferred, when image sizes changed between sites, or when a derivative was deleted. Regenerating sizes is safer than editing every post by hand when the original attachment remains available.

The protocol, CDN, or multisite path changed

Mixed http/https URLs, a changed CDN host, and altered multisite paths are distinct failure classes. Treat each old base URL as a deliberate replacement target rather than running a broad, unreviewed database edit.

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.

Start with a failure-class check

Inspect a broken image in the browser and copy its complete URL. Compare that URL with the destination site’s canonical address and with the files on disk.

  1. Check the hostname and protocol. Look for the old domain, an old CDN hostname, or http where the site now uses https.
  2. Check the path. Determine whether the URL contains an old subdirectory such as /blog/ or an obsolete uploads path.
  3. Check the filename. Remove a suffix such as -300x200 mentally and see whether the original file is present.
  4. Check the destination filesystem. Look under wp-content/uploads for the year/month directory and exact filename. Also check capitalization; Linux hosts treat Photo.JPG and photo.jpg as different files.
  5. Check the HTTP response. A 404 generally indicates a wrong path or missing file. A 403 points toward permissions or server rules. A successful response with a broken display can indicate an invalid file or an application-level rewrite.

Do not begin with a database replacement until you know which of these conditions applies. Replacing a URL will not fix an absent file, and regenerating thumbnails will not fix a URL that still uses the old domain.

Back up before changing anything

Export the current database and copy the WordPress files and the entire uploads directory to separate storage. Keep at least one copy outside the web server. The WordPress handbook recommends downloading a copy of the main WordPress files before changing wp-config.php and site URLs, and Better Search Replace cautions that an incorrect search or replacement string can damage the database.

  • Export the database in a format you can restore, and record the export date.
  • Copy wp-content/uploads, including year/month subdirectories and any custom media directories.
  • Preserve the current wp-config.php and note the existing WP_HOME or WP_SITEURL constants.
  • Do not overwrite the only backup with a second export after the replacement.

Test that the backup can be opened or restored in a disposable environment before making a large replacement. This is particularly important when serialized settings are present.

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

Confirm the canonical WordPress URLs

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

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

When a site moved from a subdirectory, these addresses may differ from the values used on the source site. The handbook states that both addresses must be changed during a move and notes that existing media links can continue pointing to the old folder. If the dashboard is inaccessible, the values can be defined temporarily in wp-config.php; remove temporary constants after the database has been corrected so two competing sources of truth do not remain.

Choose the repair that matches the failure

Observed condition Correct first action Why
The file exists, but its URL has the old domain, folder, protocol, or CDN host Serialization-aware URL replacement The binary file is already available; only stored references need changing.
The file is absent from the destination Copy or re-import the attachment A text replacement cannot create a missing upload.
The original exists, but a requested resized filename is absent Regenerate the registered image size WordPress can recreate derivatives from the original attachment.
The source is being imported from WXR and links still point to the old site Use the import URL-rewrite and local-source options The importer can rewrite old links while matching files already in a local uploads directory.

Repair old URLs with WP-CLI

WP-CLI is the most controlled option when you have SSH access. Its search-replace command understands serialized data, which matters because WordPress stores arrays and objects with lengths that must change when a URL changes.

1. Preview the replacement

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

Review the reported tables and counts. Use the exact old base URL, including protocol and any subdirectory. A replacement from old.example to new.example can affect values you did not intend to touch if both strings occur in unrelated data.

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.

2. Export before the live edit

WP-CLI documents export controls for search-replace operations. Save a fresh database export before the non-dry run and retain the earlier full backup. If you are working on a multisite installation, use the command’s multisite mode and verify whether the replacement should cover the network or only a site.

3. Run against the intended tables

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

The command above illustrates the documented practice of skipping the guid column when appropriate. Select the tables deliberately rather than assuming every table should be changed. WP-CLI’s serialized-data-aware processing is the reason this method is preferable to a raw SQL REPLACE() across the database.

4. Handle more than one old base URL

If the site used both an old domain and an old CDN hostname, preview and perform each replacement separately. Keep a record of every source and destination pair. Do not combine unrelated changes in one opaque operation; separate runs make the result easier to verify and reverse.

Use a dashboard workflow when SSH is unavailable

Better Search Replace provides a dashboard-based alternative. The 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.
  2. Install the plugin on the destination site.
  3. If necessary, define the new site URL temporarily in wp-config.php so WordPress can load at the intended address.
  4. Enter the old URL as the search value and the new URL as the replacement value.
  5. Run the tool’s dry run or preview, inspect the affected tables, and then perform the replacement.
  6. Remove the temporary URL constant after the database values are correct.
  7. Open Settings → Permalinks and click Save Changes if rewritten links or attachment pages still behave incorrectly.

Check spelling, protocol, trailing slashes, and subdirectory paths before submitting. The plugin’s own FAQ explicitly warns that a wrong search or replacement string could damage the database. Use this method for serialized data rather than an ordinary text editor or blind SQL query.

Restore attachments that never arrived

When the destination lacks the original file, restore the file first and then verify the attachment record. WP-CLI’s media command can create an attachment from a local file or a URL:

wp media import /path/to/image.jpg --post_id=123

You can also provide a source URL to wp media import when the file is accessible there. Replace the example post ID with the post that should own the attachment when an association is required. Confirm that the imported file appears in the Media Library and that its generated metadata was created.

Use WXR import options for a repeatable migration

For WordPress eXtended RSS (WXR) imports, the wp import command includes options designed for migration:

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

--rewrite_urls changes imported links that point to the previous site so they point to the current site. If matching files are already present in a local uploads directory, --source-dir lets the importer reuse them instead of attempting to download them again:

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

These options address different layers: URL rewriting changes references, while the source directory supplies the actual media files. Neither option substitutes for checking permissions and readability on the destination.

Fix missing thumbnails and responsive variants

First establish that the original attachment exists and opens. Then check which size the page requests. A missing image-768x512.jpg with a healthy original is a derivative problem, not a reason to replace every post URL.

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.

Regenerate registered sizes

Use the WordPress media command set to regenerate thumbnails, including an only-missing operation when you want to avoid rewriting existing derivatives:

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

For a targeted repair, pass the attachment ID to regenerate that item rather than the entire library. The available sizes are determined by the destination site’s registered image-size settings, so compare those settings with the source site before expecting an exact filename. If the destination no longer registers the old size, add or restore that size first, then regenerate.

Replace an attachment without changing its identity

When the original file is corrupt or was replaced on the source site, use the media command that replaces an attachment file while preserving the attachment’s identity. This keeps references to the attachment ID intact and lets WordPress rebuild metadata and derivatives. Make a backup before replacing a file, because a replacement can invalidate existing crops or captions.

Do not manually edit every resized URL

Manual content editing is appropriate only when the original attachment is gone and no trustworthy copy can be restored. If the attachment and registered size still exist, regeneration repairs the derivative consistently across posts, featured images, and responsive markup.

Check permissions and server behavior

If the file is present but requests fail, inspect ownership and permissions on the uploads directory and its parent directories. The web server must be able to traverse directories and read image files. Also check server rewrite rules, hotlink protection, security plugins, and CDN origin settings. A 403 response is not solved by changing a database URL; it requires correcting access policy.

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

Use the browser’s developer tools to inspect the Network panel. Record the requested URL, status code, response headers, and whether the response is coming from the origin or a cache. Clear page caches and CDN caches only after the origin serves the correct file, otherwise a stale 404 can conceal a successful repair.

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

After each repair method, test representative content:

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
  • Several ordinary posts and pages.
  • Custom post types and templates with custom fields.
  • Featured images and archive thumbnails.
  • Images inserted through the block editor and classic editor.
  • Responsive srcset and sizes variants at more than one viewport width.
  • Images in widgets, menus, sliders, and theme-controlled backgrounds.

Crawl those URLs and inspect the browser’s network responses for 404s. Purge page and CDN caches, then repeat the check. There is no universal success-rate statistic for these repairs; completion is established by confirming that the rendered URLs resolve and that the expected image dimensions load.

Troubleshooting branches

The URL still shows the old domain after replacement

Run a new dry run using the exact string visible in the broken URL. The value may include a subdirectory, a different protocol, an encoded character, or a CDN hostname that was not included in the first replacement. Check post content, post meta, options, and widget data rather than assuming the reference is in one table.

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

The replacement ran, but images still return 404

Compare the rewritten URL with the physical path under wp-content/uploads. If the file is absent, restore it with a file copy or media import. If the filename differs, confirm whether the attachment was re-uploaded and whether its metadata points to the new file.

The original loads, but one thumbnail size still fails

Confirm that the size is registered on the destination and regenerate only the missing derivatives. A source site may have used a custom image size that the destination theme or plugin no longer registers.

The site breaks after a database replacement

Restore the pre-change database backup, then repeat the operation with a serialization-aware tool and a narrower search string. Do not attempt to repair serialized values with a plain SQL replacement or a text editor. Recheck the old and new strings character by character, including trailing slashes.

Images work for logged-in users but not visitors

Compare cached and uncached responses. Purge page and CDN caches, inspect access-control rules, and verify that the public request reaches the same origin file. A cache can preserve an old 404 after the database and filesystem are correct.

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

WP-CLI and dashboard replacement compared

Consideration WP-CLI Better Search Replace
Access required SSH or another command-line route to WordPress Dashboard access on the destination site
Preview --dry-run previews affected values Documented dashboard sequence includes a preview or dry-run before the live replacement
Serialized data Serialization-aware search and replace Designed for safe replacement in serialized WordPress data
Exports and scope Supports exports, table selection, multisite mode, and documented column exclusions Works through selected database tables in the dashboard workflow
Best fit Operators who need repeatable, auditable commands Site owners who cannot use SSH

Both approaches still require a backup and a separate check that the files exist. Tool choice does not change the underlying diagnosis.

URL replacement versus re-import

Use URL replacement when the image file is already on the destination and only its stored address is stale. Use attachment re-import when the destination has no readable copy. If some files exist and others do not, combine the methods: restore the missing files, then run a narrowly scoped URL replacement for the references that still use the old base URL.

Thumbnail regeneration versus manual editing

Regeneration is the preferred repair when the original attachment and the required registered size are available. It updates the derivative files and metadata consistently. Manual editing is a fallback for orphaned content where no original can be recovered, but it leaves future responsive variants and attachment metadata at risk. Restore the source file whenever possible.

A practical order of operations

  1. Capture one broken URL and classify the failure.
  2. Back up the database, WordPress files, and uploads to separate storage.
  3. Confirm WordPress Address and Site Address under Settings → General.
  4. Check the destination filesystem, permissions, and exact filenames.
  5. Preview and run a serialization-aware URL replacement if the files exist.
  6. Use WXR rewrite options or wp media import for attachments that are missing.
  7. Regenerate registered thumbnails when only derivatives are absent.
  8. Save Permalinks if rewritten links still misbehave.
  9. Clear caches and crawl posts, pages, custom post types, featured images, and responsive variants.

The reliable principle is simple: repair references only after confirming the files, restore files when they are missing, and regenerate derivatives only from a verified original. That sequence prevents a URL edit from being mistaken for a file recovery and avoids damaging serialized WordPress data.

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

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.