WordPress Images Not Showing: Which URL Broke and Why
WordPress builds image URLs in two places: the Media Library rebuilds them from the uploads base URL on every request, while posts keep the URL that was inserted. Find which one is wrong, then fix that one.
Quick answer: open the broken image's URL in a new tab. A 404 means the file or the stored URL is wrong, a 403 means the server refuses it, and an image that loads fine means the page markup or a script is at fault. Re-uploading fixes none of these.
Two sources of image URLs
Attachments (Media Library, featured images, galleries). Each attachment stores its file path relative to the uploads folder in the _wp_attached_file field, for example 2026/11/photo.jpg. wp_get_attachment_url() adds that path to the uploads baseurl on every request. The baseurl comes from, in order of priority:
- an
upload_dirfilter in a plugin or theme (applied last, overrides everything); - the
UPLOADSconstant inwp-config.php: a folder relative to the WordPress install, with the URL built from the WordPress Address (URL); - the
upload_url_pathoption, if not empty; - otherwise
WP_CONTENT_URL+/uploads, andWP_CONTENT_URLdefaults to the WordPress Address +/wp-content.
Images inside post content. The block editor writes the full URL into the post, such as <img src="https://old.example/wp-content/uploads/2026/11/photo.jpg">. That text never changes on its own. When WordPress renders the post, it adds a srcset attribute, and the srcset URLs are rebuilt from the current baseurl, not from the stored src.
So after a migration you can have a correct library and broken posts, or the reverse. Even inside one image tag, src and srcset can point to different hosts.
Symptom → what to inspect → cause → fix
| Symptom | Inspect | Likely cause | Fix |
|---|---|---|---|
| Library grid stays empty or the spinner never stops | DevTools → Network → the admin-ajax.php request with action=query-attachments |
Response is not clean JSON (PHP warning or HTML before it), a fatal error in a plugin, or a 403 from a security rule | Fix the error the response shows, or deactivate the plugin that adds it |
| Grid shows "No media items found." but files exist on disk | Same request: the response contains "data":[] |
Files were copied without the database rows | Import the database, or register the files with wp media import |
| Library tiles broken, originals open fine | Open the tile's image URL, e.g. photo-300x300.jpg |
Sub-size files missing after a partial copy | Regenerate thumbnails |
| Every attachment URL points to the wrong host or folder | wp_get_upload_dir() → baseurl |
Stale upload_url_path, upload_path, UPLOADS or WordPress Address |
Correct the setting (below) |
| Images in posts 404, library fine | Page source → src of the <img> |
Old domain or folder hard-coded in post content | Search-and-replace the database |
src opens but the image is still broken in the browser |
Page source → srcset |
baseurl is wrong; browsers use srcset first |
Fix baseurl, not the posts |
| 403 Forbidden on the file URL | Open it directly, then from the page | Permissions, hotlink protection, security rule | See the 403 section |
| Console says "Mixed Content", only on HTTPS | Console → the blocked http:// URL |
http:// stored in posts or in the WordPress Address |
Fix mixed content |
| Theme 404 page or homepage instead of the image | The file path on disk | The file is not there, so the request fell through to WordPress | Restore wp-content/uploads from backup |

Check what WordPress thinks the uploads folder is
- Tools → Site Health → Info → Directories and Sizes shows Uploads directory location, the filesystem
basedirafter any filters (single sites only). - With WP-CLI,
wp eval 'print_r( wp_get_upload_dir() );'printsbasedir,baseurl,path,urlanderror.baseurlshould be your current domain followed by/wp-content/uploads, or your CDN host. - Settings → Media normally shows only the "Organize my uploads into month- and year-based folders" checkbox. The Store uploads in this folder and Full URL path to files fields appear only when one of them already has a non-default value. If you can see them, someone set them, often an old CDN or migration plugin. The defaults are
wp-content/uploadsand an empty URL. Clear both and save. - If neither shows anything unusual, search
wp-config.phpforUPLOADSandWP_CONTENT_URL, and the active plugins for anupload_dirfilter. How that filter works is covered in the upload_dir filter.
Remember that UPLOADS and the default WP_CONTENT_URL both build the URL from the WordPress Address. Change that address, or switch it from http to https, and every attachment URL changes with it. See WP_HOME and WP_SITEURL for where that value can be overridden.
After a migration or domain change
- Confirm the files arrived:
wp-content/uploads/2026/11/should contain bothphoto.jpgand its sized copies. If the folder is empty, copy it again. The database rows are already fine. - Replace the old URL in the database with a tool that handles serialised data. A plain SQL
REPLACEcorrupts serialised options and widget settings.
wp search-replace 'http://old.example' 'https://new.example' --skip-columns=guid --dry-run
wp search-replace 'http://old.example' 'https://new.example' --skip-columns=guid
- Clear page and CDN caches, then look at the
srcandsrcsetof one image in the page source. Both should show the new host.
The full move checklist is in how to migrate a WordPress site to a new host.
403: the server refuses the file
WordPress creates new month folders with their parent folder's permission bits. Each uploaded file gets its folder's bits minus the execute bits. So if wp-content/uploads is 0700 or 0750 and the web server runs as a different user, every new upload is unreadable while older images keep working. Set folders to 755 and files to 644, owned by the account PHP runs as. 777 creates a security hole and fixes nothing that 755 does not.
If permissions are fine, look for:
- hotlink protection at the host or CDN, which blocks requests whose referrer it does not recognise (including your own new domain);
- an
.htaccessfile insidewp-content/uploadsadded by a security plugin; - a CDN serving a cached 403. Purge the path after fixing the origin.
The file loads, the page shows nothing
- Check the
<img>tag. If it has onlydata-srcand a placeholdersrc, a lazy-loading script did not run. Look in the console for its error, and see lazy loading images in WordPress for conflicts between theme and plugin lazy loading. - A
Content-Security-Policyheader that does not allow your CDN host blocks the image. The console names it. - Purge plugin, host and CDN caches and test in a private window.
If new uploads fail instead of old images disappearing, that is a different problem: start with Post-processing of the image failed.
Common mistakes
- Re-uploading. This creates a new attachment with a new URL. Posts still point to the old one.
- Setting "Full URL path to files" to fix one image. It changes the
baseurlof every attachment on the site. - Running search-replace on the
guidcolumn. GUIDs are identifiers, not links. Leave them alone. - Regenerating thumbnails when the originals are gone. Regeneration needs the original file. Restore it from a backup first.
Verify
- One old and one new image open directly with a 200 response.
- In the page source,
srcand everysrcsetentry use the same, current host. - The Media Library grid loads, and its
query-attachmentsresponse starts with{"success":true.
Frequently asked
- Either the uploads folder was not copied, or the old domain is still stored somewhere. Images inserted into posts keep their full URL in the post content, so they need a serialisation-safe search-and-replace. If the Media Library is also broken, check the WordPress Address and any upload_url_path value.
- No. The grid shows a generated sub-size such as photo-300x300.jpg, not the original. If those files were not copied or were deleted, the tiles break while the originals are fine. Regenerating thumbnails rebuilds them from the originals.
- The admin and the front end can request different URLs. On an HTTPS front end WordPress upgrades attachment URLs to https, posts keep whatever URL was inserted, and srcset is rebuilt from the uploads base URL. A CDN, cache or hotlink rule can also affect only public requests.