This Snippet Finds Your Unused Images (So You Can Delete Them Safely) 🛡️

Table of Contents

If you’ve managed a WordPress site for more than a month, you know the pain. Your Media Library quickly becomes a graveyard of “Draft_v2” images, forgotten PDFs, and custom fonts from a redesign three years ago.

The problem? WordPress doesn’t reliably tell you what is safe to delete. Standard “cleaner” plugins are often bloated, risky, or—worse—require expensive API credits to scan your own files.

That changes now. With the Media Usage Scanner snippet, you get a high-performance audit of your images, fonts, videos, and PDFs without the bloat. đź’Ž

đź§  What the Media Usage Scanner actually does

Unlike “guess-based” tools, this scanner identifies exactly where a file is used across your entire site DNA. It tracks media hidden inside:

  • Post & Product Content: Standard layouts and WooCommerce stores.

  • Page Builders: Elementor templates, carousels, and flexbox containers.

  • Header Templates: Including those tricky SVGs.

  • Button Triggers: Finding the PDFs linked to buttons that standard scanners miss.

The “New Way” Advantage: This is a pure code snippet. No AI credits, no “metered” scanning, and zero background bloat. Just logic. 🏎️

⚙️ How it works: Batch scanning for large libraries

Huge libraries usually choke standard plugins. This scanner works in intelligent batches, meaning it stays fast even if you have thousands of assets.

You can audit your entire library or use precision filters to focus your scan:

  1. Date Ranges: Audit only what you uploaded this week.

  2. Keyword Search: Want to see if “Imran-Headshot.jpg” is actually being used? Just type the name and scan.

📄 It’s not just for images

Most tools stop at JPEGs. This scanner looks deeper into your assets:

  • PDFs: Flags files attached to buttons, even if they aren’t “visible” on the page.

  • Videos: Detects files tucked inside video widgets and background containers.

  • SVGs & Fonts: Correctly identifies SVGs in your headers and custom fonts loaded via Elementor.

Pro-Tip: If you see a font marked “Unused,” double-check your Elementor Custom Font settings before hitting delete. The scanner is thorough, but font-naming conventions can be tricky. đź§·

🗑️ The Safety Net: Export before you Delete

We don’t believe in “Delete and Pray.” The Media Usage Scanner is built for professional workflows:

  • Locked Selection: The UI physically prevents you from selecting “Used” items. You can only delete what the scanner confirms is dead weight.

  • The Zip Backup: Before the deletion executes, the tool can export all unused items into a zipped backup.

  • The Result: Your Media Library is instantly lighter, and you have a safety fail-safe sitting in your downloads folder just in case. 🛡️✨

📌 How to set it up (The 60-Second Workflow)

A Big shout out to Imran Siddiq – Web Squadron for sharing this video.

âť“ FAQ: The “New Way” to Clean Your Library

Yes. The UI is built with a safety lock—you can only select items marked as “Unused.” This prevents accidental “site-breaking” deletions of active assets. 🛡️

No. This is pure, local logic. Since it’s a code snippet, it runs on your server without needing external “metering” or extra costs. đź’Ž

Absolutely. Unlike basic scanners that only look at “visible” images, this logic tracks file URLs triggered by buttons and links, marking them as “Used” even if they aren’t on the front page. đź“„

 We’ve got you covered. Before any file is removed, the scanner offers to export a Zipped backup of the unused items. If you realize you needed that old font, just re-upload it from the zip. 📦

The scanner detects fonts configured within Elementor’s custom setup. However, always double-check your font naming before a mass delete, as some legacy theme fonts may be referenced in ways the database doesn’t “see” immediately. đź§·

Picture of Andrea Morgado
Andrea Morgado
She’s a strategist at heart and a compulsory problem-solver who turned “helping brands grow” into a long-term career. As Marketing Lead at Code Snippets, she spends her days shaping stories, building visibility, and translating complex ideas into language humans can understand.. without buzzwords, fluff, or unnecessary SEO filler words. With 15 years of experience across branding, design, web design, and digital marketing, she believes in long-term thinking, clear communication, and doing the work properly before dropping it on LinkedIn. Away from the screen, she’s powered by curiosity, creativity, and a suspiciously reliable ability to spot what’s broken, confusing, or missing, and quietly fix it before anyone else notices.
Share this Post on Social
Facebook
Twitter
LinkedIn
Email

Table of Contents

Rapyd Cloud (3-Day Free Trial)

Rapyd Cloud recently upgraded the standard for a WordPress Performance Stack by including Enterprise Cloudflare CDN on every plan. This isn’t just a basic CDN; it’s a deep integration that moves your site’s delivery to the “Edge.” 

The Code Snippets Pro Affiliate Program
Turn Your Referrals into Revenue.

Love using Code Snippets? Share the “Pro Way” with your audience and earn a 30% lifetime commission on every sale. It’s fast to join, easy to track, and built for your long-term success.