You open Media > Library, and the grid just spins. Forever. No error, no images, just a loading icon that never gives up. When the WordPress media library is not loading, your files are almost never gone. Something is blocking the one background request that fills the grid, and once you know where to look, it usually takes minutes to find.
This guide walks through the exact order to check things in: the 30-second test that tells you where the problem lives, how to read the actual error in your browser, and the fixes for each cause, from plugin conflicts to broken thumbnails.
Why Is My WordPress Media Library Not Loading?
The WordPress media library grid loads its files through a background AJAX request to admin-ajax.php (the query-attachments action), which must return clean JSON. If a plugin, theme, PHP error, security rule, or memory limit breaks or corrupts that response, the grid spins forever or shows nothing, even though every file is still on the server.
That single detail explains almost every case. The grid view is a JavaScript app. It doesn’t render your images directly. It asks the server for a list of attachments, waits for JSON, then builds the grid from it. If anything gets in the way of that request, the JavaScript has nothing to work with.
The most common causes, roughly in order of how often they show up:
- A plugin or theme conflict that throws a JavaScript error or injects output into the AJAX response
- PHP warnings or notices printed to the screen, which corrupt the JSON before WordPress sends it
- A firewall or security rule (security plugin, ModSecurity, Cloudflare WAF) blocking
admin-ajax.php - PHP memory exhaustion on large libraries
- Wrong file permissions or URLs, which cause grey or blank thumbnails rather than a stuck grid
Step 1: Switch to List View (the 30-Second Test)
Switching the WordPress media library to list view is the fastest way to tell whether your files exist and whether the problem is the AJAX request. Go to /wp-admin/upload.php?mode=list. If your files appear there, the uploads and database are fine and the grid’s background request is what’s failing.
List view is rendered by plain PHP on page load. It doesn’t use the JavaScript grid or the query-attachments request at all. That makes it a perfect diagnostic split:
- List view works, grid view spins: it’s a JavaScript or AJAX problem. Keep reading, this is the common case.
- List view shows files but thumbnails are broken: it’s a file path, permissions, or URL problem. Jump to the thumbnails section below.
- List view is empty too: the attachments may be missing from the database (common after a bad migration), which is a different problem entirely.
List view is also a decent workaround if you need to grab a file URL right now while you fix the real issue.
Step 2: Read the Real Error in Your Browser
Your browser’s developer tools show exactly why the WordPress media library grid is failing, which saves you from guessing. Open the Media Library, press F12, and check the Console tab for red JavaScript errors and the Network tab for the admin-ajax.php request and its status code.
Here’s how to read it:
- Open Media > Library in grid view.
- Press F12 (or right-click and choose Inspect), then open the Network tab.
- Reload the page and type
admin-ajaxin the filter box. - Click the request and check the Status and the Response tab.
A healthy response starts with {"success":true,"data":[. Anything else points straight at the cause:
| What you see | Likely cause | Fix |
|---|---|---|
| Status 200, but the response starts with a PHP warning, HTML, or blank space | A plugin or theme printing output before the JSON | Hide on-screen errors, then find the plugin (Steps 3 and 4) |
| Status 403 Forbidden | Security plugin, ModSecurity, or Cloudflare WAF blocking the request | Whitelist admin-ajax.php or the rule (Step 5) |
| Status 500 Internal Server Error | PHP fatal error or memory exhaustion | Check debug.log and raise memory (Step 6) |
| Status 200 with clean JSON, but red errors in the Console | JavaScript conflict from a plugin or theme | Plugin and theme conflict test (Step 4) |
| Grid loads, but thumbnails are grey or broken | Permissions, wrong URLs, mixed content, or missing image sizes | Fix thumbnails (grey thumbnails section) |
Step 3: Stop PHP Notices From Breaking the JSON
PHP notices and warnings printed to the screen are one of the most overlooked causes of a WordPress media library not loading. A single line like “Deprecated: …” in front of the JSON makes it invalid, and the grid silently gives up. The fix is to log errors to a file instead of displaying them.
Open wp-config.php and make sure your debug settings look like this (above the “That’s all, stop editing!” line):
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
Reload the Media Library. If the grid now works, the underlying warning is still there, it’s just no longer corrupting the response. Open wp-content/debug.log to see which plugin or theme file produced it, then update or replace that plugin. When you’re done, set WP_DEBUG back to false on a live site.
One more classic culprit in the same family: blank lines or spaces after a closing ?> tag in a theme’s functions.php. That stray whitespace gets sent before the JSON too. Removing the closing tag at the end of the file is the standard fix.
Step 4: Find the Plugin or Theme Conflict
A plugin or theme conflict is the single most common reason the WordPress media library grid stops loading, especially right after an update. Deactivate all plugins, check whether the grid loads, then reactivate them one at a time until it breaks again. The last plugin you activated is the cause.
Plugins that touch the media screen deserve suspicion first: media folder organizers, image optimization plugins, page builders, and anything that adds fields to attachments. If deactivating every plugin doesn’t fix it, switch to a default theme like Twenty Twenty-Five to rule out the theme.
On a live business site, deactivating everything in front of visitors isn’t ideal. The Health Check & Troubleshooting plugin solves this with a troubleshooting mode that disables plugins only for your logged-in session. The full process is covered in how to find which WordPress plugin is causing a problem.
This isn’t a new problem either. WordPress core has tracked media grid regressions before, such as Trac ticket #36777, where the grid view stopped working for some sites after the 4.5.1 update. If the issue started right after a core update, check the WordPress.org support forums for the same report before tearing your site apart.
Step 5: Check Security Rules Blocking admin-ajax.php
A 403 Forbidden response on admin-ajax.php means a security layer is blocking the WordPress media library request before WordPress even sees it. The usual suspects are security plugins, the server’s ModSecurity firewall, and Cloudflare WAF rules. The fix is to whitelist the request, not to switch security off.
- Security plugins: check the plugin’s firewall or blocked-requests log for your own IP and the
admin-ajax.phpURL. Wordfence, for example, has a learning mode and lets you allowlist a blocked action. - ModSecurity: ask your host to check the server’s ModSecurity log for the request. Hosts can disable the single rule causing the false positive.
- Cloudflare: check Security > Events for blocked requests to
/wp-admin/admin-ajax.php, and make sure no cache rule is caching anything under/wp-admin/.
Never “fix” a 403 by turning off the firewall entirely. Whitelist the specific rule and keep the protection on. The same troubleshooting logic applies to the wider error, covered in WordPress 403 Forbidden error: what causes it and how to fix it.
Step 6: Fix 500 Errors and Memory Limits
A 500 error on the media library request usually means PHP crashed while building the attachment list, often because it ran out of memory on a large library. Check wp-content/debug.log for an “Allowed memory size exhausted” message, then raise the admin memory limit in wp-config.php.
WordPress uses a separate, higher memory limit for admin requests, including admin-ajax.php. Set it explicitly:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
These constants can’t go above the PHP memory_limit your host allows. If the server caps you at 128M, nothing in wp-config.php will override it, and you’ll need to raise it in cPanel’s PHP settings or ask your host. The full breakdown, including how to find what’s actually eating memory, is in WordPress memory exhausted error: how to fix it.
If the log shows a fatal error from a specific plugin file instead, that’s your answer. Update or replace that plugin.
Why Is My Media Library Not Showing Images (Grey or Blank Thumbnails)?
When the WordPress media library loads but shows grey boxes or broken thumbnails, the grid itself is working and the image files can’t be fetched. The cause is usually wrong file permissions, a changed site URL, mixed HTTP/HTTPS content, hotlink protection, or missing thumbnail sizes. Right-click a broken thumbnail and open it in a new tab to see the actual error.
Work through these in order:
- File permissions. Folders in
wp-content/uploadsshould be 755 and files 644. Over SSH, run the commands below from your WordPress root. - Site URL. In Settings > General, the WordPress Address and Site Address must match your real domain and protocol. After a migration, old URLs in the database are a frequent cause of broken thumbnails.
- Mixed content. If the site runs on HTTPS but image URLs still use HTTP, browsers block them. See how to fix a WordPress mixed content error.
- Hotlink protection or CDN rewrites. Hotlink rules in cPanel or Cloudflare, or a CDN plugin rewriting image URLs to a domain that no longer serves them, both break thumbnails.
- Missing image sizes. If the originals exist but thumbnails don’t, regenerate them with the Regenerate Thumbnails plugin or WP-CLI.
find wp-content/uploads -type d -exec chmod 755 {} \;
find wp-content/uploads -type f -exec chmod 644 {} \;
# Regenerate missing thumbnails with WP-CLI
wp media regenerate --only-missing
If the problem is uploading new images rather than viewing existing ones, that’s a different issue with different fixes, covered in WordPress HTTP error uploading images.
Don’t Forget the Boring Fix: Cache
Stale browser cache, a page caching plugin, or a CDN serving old admin JavaScript can all keep the WordPress media library broken after you’ve already fixed the real cause. Clear your browser cache (or test in a private window), purge your caching plugin, and purge your CDN before deciding a fix didn’t work.
Admin pages should never be cached by a page cache in the first place. If your caching plugin or a Cloudflare cache rule is touching /wp-admin/, exclude it. For tracking down which layer is holding old files, see WordPress changes not showing.
The Bottom Line
A WordPress media library that won’t load is almost always a broken AJAX response, not lost files. Check list view first, open the Network tab second, and let the status code tell you which fix to apply. That order turns a frustrating guessing game into a short checklist, and it works the same way on every WordPress site.
If you’d rather have someone else dig through the logs, take a look at past WordPress projects and get in touch.
Frequently Asked Questions
A WordPress media library stuck loading usually means the background admin-ajax.php request that fills the grid is failing or returning invalid JSON. The most common causes are a plugin or theme conflict, PHP warnings printed into the response, a security rule blocking the request, or PHP running out of memory.
WordPress media library list view is rendered with plain PHP when the page loads, while grid view depends on JavaScript and an AJAX request to admin-ajax.php. If list view works and grid view doesn’t, your files are fine and the problem is a JavaScript error or a broken AJAX response, usually caused by a plugin or theme.
Grey or blank thumbnails in the WordPress media library mean the grid loaded but the browser can’t fetch the image files. Check that upload folders are 755 and files are 644, that the Site URL matches your domain and HTTPS setting, and that hotlink protection or a CDN isn’t rewriting image URLs.
No, a WordPress media library that won’t load almost never means your images are deleted. The files stay in wp-content/uploads and the records stay in the database. Open /wp-admin/upload.php?mode=list to confirm the files are still listed.
Yes. Security plugins, server ModSecurity rules, and Cloudflare WAF rules can block the admin-ajax.php request the WordPress media library depends on, which shows up as a 403 error in the browser’s Network tab. Whitelist the specific blocked rule rather than disabling the firewall.

Leave a Reply