The Problem: Featured Images Disappeared After Cleanup
What Happened and Why
After a server-side file cleanup — particularly one involving FTP deletion of specific image files — it is possible to accidentally delete files that WordPress was actively referencing as featured images for posts. The result is that posts which previously displayed a featured image on archive pages, in search results, and in social sharing previews now show a broken image or no image at all.
This situation arose on one project when thumbnail-sized JPG files were deleted from the server to resolve a WebP conversion issue. Some of those thumbnail files happened to be the specific image size that WordPress was referencing as the featured image for certain post types. When the files were deleted, the featured image reference in the database still pointed to a file that no longer existed.
Understanding What WordPress References
WordPress stores featured images as attachment post IDs in the database. The attachment record contains metadata about the image including its URL, file path, and the URLs of all generated thumbnail sizes. When WordPress displays a featured image, it looks up the attachment record and serves the image size most appropriate for the context.
If the file at the referenced URL no longer exists on the server, WordPress cannot display the image. The attachment record remains in the database — the featured image is still technically assigned — but the file is missing. This is why the WordPress admin may still show a featured image in the post editor while the frontend shows a broken image.
Diagnosing the Scope of the Problem
Identifying Affected Posts
The fastest way to identify which posts are affected is to check the archive or category pages where featured images are displayed. Any post showing a broken image or missing thumbnail has a missing file. For a thorough audit, use a broken link checker plugin or a tool like Screaming Frog to crawl the site and flag 404 responses for image URLs.
Fixing Missing Featured Images
Re-uploading the Original Image
If the client has a local backup of the original image, the most reliable fix is to re-upload the image through the WordPress media library and reassign it as the featured image for each affected post. This creates a new attachment record with a new file on the server, and WordPress generates all required thumbnail sizes from the fresh upload.
For a small number of affected posts, this is the most practical approach. For a large number of affected posts, a programmatic solution — a script that re-assigns featured images in bulk — is more efficient.
Restoring Files via FTP
If the deleted files can be recovered from a hosting backup, restore them to their original paths via FTP. WordPress will immediately be able to serve them again without any database changes — the attachment records still reference the correct paths, so once the files are back in place, the featured images will reappear.
Most shared hosting providers retain automatic daily or weekly backups. Access these through the hosting control panel and restore only the affected upload directory rather than the entire WordPress installation.
Regenerating Thumbnails
If the original full-size image still exists on the server but the specific thumbnail size being referenced has been deleted, regenerating thumbnails will recreate the missing file. Install the Regenerate Thumbnails plugin, run it from the WordPress admin, and it will recreate all registered image sizes for every attachment in the media library. This is the preferred fix when the original files are intact but specific sizes are missing.
Preventing This in Future Cleanup Operations
Before any FTP-based file deletion, generate a list of all image URLs that WordPress is actively referencing as featured images. This can be done with a simple database query against the wp_postmeta table where the meta key is _thumbnail_id, then looking up the corresponding attachment URLs in wp_posts. Cross-reference this list against the files targeted for deletion before proceeding.
The final article in this series brings everything together in a before-and-after walkthrough of a complete WordPress speed audit — from an initial mobile PageSpeed score in the low 60s to a final score above 90.
This article is part of our complete guide:
WordPress Speed Optimization: A Complete Developer Guide
Read the full guide →