Last checked: 10 November 2026 against WordPress.org and WP-CLI documentation and Media Purge 1.4.7. Disclosure: we make Media Purge.
You open Media → Library and the grid is empty, the spinner never stops, or the thumbnails show as grey boxes. Your files are usually still there. The Media Library is a list of database records (attachments) that point to files in wp-content/uploads, and the grid view loads them in the background with JavaScript. When any link in that chain breaks, images stop showing. This guide walks through the checks in the order that finds the cause fastest.
Quick triage: symptom, likely cause, first check
| What you see | Likely cause | Start with |
|---|---|---|
| Grid view is empty or loads forever | JavaScript or AJAX error, often from a plugin or theme | Fix 1, 2 and 3 |
| List view works, grid view does not | The grid’s background request is failing | Fix 2 and 3 |
| Items listed, but thumbnails are broken | Wrong file URLs, missing files or missing image sizes | Fix 6, 7 and 8 |
| Everything broke after moving the site or switching to HTTPS | Old URLs still stored in the database | Fix 7 |
| Files are in the uploads folder but not in the library | Files were copied by FTP, so no attachment records exist | Fix 9 |
| New uploads fail or do not appear | Folder permissions, upload path or memory | Fix 4 and 5 |
Before you change anything, take a backup of the database and the wp-content/uploads folder, and make sure you know how to restore it. Several fixes below edit the database or wp-config.php. If you need a full walkthrough of host, plugin, WP-CLI and manual backups, see how to back up a WordPress site (draft until published).
1. Switch to list view
Go to Media → Library and click the list icon next to the grid icon (or open /wp-admin/upload.php?mode=list). List view is rendered by the server instead of loaded with JavaScript. If your files appear there, the files and database records are fine and the problem is in the grid’s background loading, so go to fixes 2 and 3. If list view is also empty, skip to fix 7 and fix 9.
2. Rule out a plugin or theme conflict
The most common cause is a plugin or theme that adds broken JavaScript to the admin, or prints output that corrupts the response the grid expects. To test without affecting visitors, install the Health Check & Troubleshooting plugin and turn on Troubleshooting Mode. Its description says Troubleshooting Mode gives you “a clean WordPress session, where all plugins are disabled, and a default theme is used, but only for your user until you disable it or log out.” Before you start, note which plugins are active (a screenshot of the Plugins screen is enough), and use a staging copy if you have one, so you can put everything back exactly as it was.
- Enable Troubleshooting Mode and reload Media → Library.
- If images now load, re-enable plugins one at a time from the Troubleshooting menu in the admin bar, reloading the library after each one.
- The plugin (or theme) that brings the problem back is the cause. Update it, check its support forum, or replace it.
Security, caching, optimization (minify or combine JavaScript) and media-related plugins are worth testing first.
3. Read the error in your browser
Open the library, then open your browser’s developer tools (F12 in most browsers).
- Console tab: red errors that appear when the library loads usually name the script or plugin file that failed.
- Network tab: reload, then look for requests to
admin-ajax.phpwithaction=query-attachments. Click one and check the Status and Response. The grid expects JSON. If you see a PHP warning, an HTML error page, a 403, a 500 or an empty response instead, that is why the grid is blank.
A 403 often points to a security plugin or a server firewall (such as ModSecurity) blocking the request; ask your host to check their logs for that request. A 500 points to a PHP error: turn on logging as in fix 4. A 200 response that starts with a warning or HTML usually means a plugin printed output into the AJAX response.
Also try a private window with browser extensions disabled, to rule out an extension blocking admin scripts.
4. Turn on debug logging and check PHP memory
To see PHP errors without showing them to visitors, add these lines to wp-config.php above the line that says “That’s all, stop editing!”:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Reload the library, then open wp-content/debug.log. Errors such as “Allowed memory size exhausted” or “Maximum execution time exceeded” explain an endless spinner. The admin uses WP_MAX_MEMORY_LIMIT, which you can raise in wp-config.php, for example define( 'WP_MAX_MEMORY_LIMIT', '512M' );. Your host’s PHP memory_limit can still cap it, so ask them if the change has no effect. Set WP_DEBUG back to false when you are done.
5. Check folder permissions and the upload path
WordPress must be able to read and write wp-content/uploads. WordPress’s file permissions guide gives 755 for folders and 644 for files as the usual setting. Folders set too strictly can stop new uploads and image sizes from being created; files that the web server cannot read show as broken thumbnails.
Also check where WordPress thinks uploads live:
- Settings → Media: if you see a “Store uploads in this folder” field, a custom upload path has been set. A wrong value here sends new files to the wrong place. If you also see “Full URL path to files”, clear a stale custom URL after a migration.
- wp-config.php: look for a
define( 'UPLOADS', ... );line. It moves the uploads folder for the whole site; remove or correct it if it points somewhere that no longer exists.
Go to Tools → Site Health → Info and open Directories and Sizes and Filesystem Permissions to confirm the uploads directory is writable, and Media Handling to see whether the GD or Imagick image library is available. Without one of them WordPress cannot create thumbnails.
6. Check your site address and HTTPS
In Settings → General, the WordPress Address and Site Address must match the address you actually use, including https:// and www. If the site runs on HTTPS but images are stored with http:// URLs, browsers can block them as mixed content and the library shows broken thumbnails.
Click a broken thumbnail, copy the File URL from Attachment details, and open it in a new tab:
- Wrong domain or http on an https site: migration or site URL problem (fix 7).
- 403 Forbidden: permissions or hotlink protection blocking your own domain (fix 5 and 10).
- 404 Not Found: the file or a resized size is missing (fix 8), or the file never arrived in the migration.
- CDN or offload URL: re-sync the offload plugin and purge the CDN cache.
7. After a migration: replace the old URLs
When a site moves to a new domain, a new folder or HTTPS, image URLs saved in the database still point to the old address. With WP-CLI, preview the change first:
wp search-replace 'https://old-domain.com' 'https://new-domain.com' --skip-columns=guid --dry-run
The dry run reports how many replacements it would make without changing anything. If the numbers look right, run the same command without --dry-run. The WP-CLI documentation recommends --skip-columns=guid so post GUIDs are left alone. If you do not use WP-CLI, use a search-and-replace tool that handles serialized data; a plain SQL REPLACE can corrupt settings stored by plugins and page builders.
Then confirm the files themselves came across: compare the year/month folders in wp-content/uploads on the old and new server.
8. Rebuild missing thumbnails
If originals exist but the smaller sizes are missing (common after a migration that skipped files, or after a theme change), regenerate them:
wp media regenerate --only-missing
--only-missing creates only the sizes that do not exist yet, which is faster and leaves existing files alone. Without WP-CLI, a thumbnail regeneration plugin does the same job from the admin.
9. Files in the uploads folder but not in the library
Copying files into wp-content/uploads by FTP or a file manager does not add them to the Media Library, because the library only lists files that have an attachment record in the database. To register files that are already in place:
wp media import wp-content/uploads/2026/11/*.jpg --skip-copy
--skip-copy adds the files to the library without copying them again. Test on a single folder first, and check you are not importing files that already have attachments, or you will create duplicates.
10. Clear caches and check the CDN
After any fix, clear your caching plugin, the server cache and the CDN. If you serve images through a CDN or an offload plugin, check that its URL settings match the current domain, and that hotlink protection is not blocking your own admin. Then reload the library in a private window.
What not to do while the library is broken
- Do not bulk-delete from the Unattached filter. Unattached only means no post parent; the file can still be used in a page builder, a widget or a product gallery.
- Do not re-upload the same images on top of broken thumbnails until you have checked the File URL. You will create exact duplicates and make the next cleanup harder.
- Do not empty the uploads folder from FTP “to start clean”. The attachment records will still point at missing files.
Once the library loads again: check what is actually in it
Libraries that have been through migrations, theme changes and repeated uploads often hold files nothing uses any more, and the same image uploaded more than once. Those files make backups and migrations bigger and the library harder to search. Before you delete anything, you need to know where each file is used.
Scan your library free with Media Purge
Media Purge is a free WordPress plugin with no scan limits. It shows where every file is used, reads Elementor data, groups exact duplicates, and moves files to a trash you can restore for 30 days by default.
Get Media Purge free on WordPress.org
Want one-click duplicate merge and scheduled cleanup when they ship? See what’s coming.
For the full process, read the WordPress media library cleanup guide, how to find and delete unused images in WordPress, and how to find duplicate images in WordPress. If the library grew after years of uploads, see why your WordPress media library gets out of control. Looking for a free Media Cleaner option with Elementor data in the free scan? Start with our Media Cleaner alternative comparison.
FAQ
Why does my media library show blank squares?
The attachment records load, but the image files do not. Open one in a new tab. A 404 means the file or the image size is missing (fixes 7 and 8); an http:// URL on an HTTPS site means mixed content (fix 6); a 403 means a permission or hotlink rule is blocking it (fixes 5 and 10).
Why is the media library stuck loading?
Usually the background request that fills the grid fails. Check the Network tab for admin-ajax.php (fix 3), then test for a plugin conflict with Troubleshooting Mode (fix 2) and check PHP memory (fix 4).
Did I lose my images?
Usually not. If list view shows your items, or the files are still in wp-content/uploads, the images are there and only the display is broken. Do not delete or re-upload anything until you have found the cause.
Will deleting unused images fix a library that does not load?
No. A slow or broken library is almost always a conflict, error, permission or URL problem. Fix that first. Cleaning up unused files afterwards keeps the library smaller and easier to manage.
Sources (checked 10 November 2026):
WordPress.org: Media Library screen ·
Health Check & Troubleshooting ·
Debugging in WordPress ·
Editing wp-config.php ·
Changing file permissions ·
Site Health screen ·
Moving WordPress ·
wp search-replace ·
wp media regenerate ·
wp media import ·
Media Purge on WordPress.org