Delete unused images safely
Why “unattached” does not mean “unused”, where page builders keep image references, and how to clean the Media Library without broken pages.
It can — and the reason is a word WordPress uses loosely. The Media Library’s Unattached filter only tells you an image was not uploaded from inside a post editor. It says nothing about whether a page uses it.
Why page builders make this risky
Divi, Elementor and other builders do not always store images the way the block editor does. A Divi module may save an image URL inside its layout data; Elementor keeps image IDs and URLs in its own JSON in post meta. A cleaner that only looks at the “attached” flag or at plain image tags will call those images unused, and deleting them leaves gaps on live pages.
A safe way to clean up
- Back up files and database first.
- Use a scanner that reads page-builder data, custom fields, widgets and theme options — not just post content. ByteKeel PixTag Pro’s Unused Media does, and when in doubt it treats an image as used.
- Review the list before deleting anything, and delete in small batches.
- Browse the pages that matter most afterwards.
What no scanner can see
Images referenced only from theme template files, hand-written CSS or JavaScript, emails or other websites are invisible to any WordPress scanner. If you hard-code images that way, keep them in a folder outside the Media Library — or tell ByteKeel PixTag Pro about them with the altgen_pro_image_is_referenced filter (see hooks and filters).
Frequently asked questions
Is “Unattached” in the Media Library safe to delete?
No. Unattached only means the image was not uploaded from a post editor. Featured images, page-builder layouts, widgets and theme settings can all use an unattached image.
Does ByteKeel PixTag Pro check Divi and Elementor layouts?
Yes. It looks for each image’s ID and file name in post content, custom fields (where Elementor and other builders keep their data) and site options, as well as featured images and attachments, and re-checks each image at the moment of deletion.
Can I undo a deletion?
Not from WordPress — deletion removes the files. Restore from your backup.
Did this answer the question? No — open a support request