Linux 软件免费装
Banner图

Freshet Unused Media

开发者 kristoffbertram
更新时间 2026年10月6日 16:51
PHP版本: 8.1 及以上
WordPress版本: 7.1
版权: GPL-2.0-or-later
版权网址: 版权信息

标签

media library attachments cleanup unused media unused images

下载

1.0.6 1.0.7 1.1.0

详情介绍:

WordPress' own "Uploaded to" column only tracks where a file was first attached — it says nothing about where a file is actually used. Files referenced from ACF fields, featured images, galleries, widgets, the customizer logo, WooCommerce product galleries or plain URLs in content all look "unattached", and genuinely unused files look no different from files your site depends on. Freshet Unused Media scans everywhere a reference can hide and tells you, per attachment, exactly where it is used — or that it provably isn't. A media library cleaner that shows its evidence: find unused images, delete or remove unused media, clean up the media library and free up disk space — without deleting a file something still shows. What it detects How it works Why the answer can be trusted Deleting media is destructive, so the scan is built to be wrong in one direction only — towards keeping the file. The "Uploaded to" relation itself is shown as informational evidence but never counts as usage — that unreliable signal is exactly what this plugin replaces. Thoroughness is the point rather than speed: a first full scan of a large library can take hours rather than minutes. It runs in batches that stop before the PHP time limit and resume where they left off, so a scan always makes progress and never has to be started over. Extensible Site-specific detectors can be added via the freshet_unusedmedia_detectors filter; freshet_unusedmedia_is_used gets the final say on any status; freshet_unusedmedia_batch_size and freshet_unusedmedia_batch_seconds tune scan batches; freshet_unusedmedia_upload_grace sets the recent-upload window in seconds (0 disables it). Part of the Freshet plugin suite. Full documentation: freshet.studio/docs. Questions and problems: freshet.studio/support.

安装:

  1. Upload the plugin and activate it.
  2. Go to Media → Usage and run a full scan.
  3. Review the unused list, then delete selected files or all unused ones.
Tip: add define( 'MEDIA_TRASH', true ); to wp-config.php so deletions go to trash instead of being permanent.

屏幕截图:

  • The Scan tab after a full scan of a village bakery's library: eight files used, twelve used nowhere, none left unscanned, with when the scan finished, what it cost and where the time went. Below it the evidence report, downloadable as CSV or JSON.
  • The Usage box on an unused file's Edit Media screen: nothing refers to it, the upload record is shown as the record it is rather than as a use, and Rescan checks it again.
  • The Usage box on a used file's Edit Media screen lists the evidence, one line per reference: the block that puts this loaf on Our breads, with the upload record beside it and marked as a record, not a use.
  • The Used tab: every file the scan found a reference for, with how many references each has, filterable by date, filename and size.
  • The Media Library list view with the Usage column and the usage status filter, including files attached to a page and still referenced nowhere.

常见问题:

Can it be wrong?

Detection is deliberately conservative: filename and structural matches are boundary-checked (attachment 123 never matches wp-image-1234), ambiguous ID matches count as used, and every file is re-verified right before deletion. What it cannot see is anything outside the tables it reads — posts, postmeta, options, term descriptions, term meta, user meta, comments and comment meta. The blind spot most worth knowing about is inside your database, not outside it: references stored in a plugin's own custom database tables — form entries, slider or page-builder records, any plugin that keeps attachment IDs or file URLs in a table of its own. No query-based scanner can find a reference in a table whose shape it has never seen. The same applies to references hard-coded in theme or plugin files, references held by an external service, references on other sites of a multisite network (network-wide options included), and the legacy Links manager. Two deliberate choices are worth knowing too. Old post revisions are not counted as usage — a file removed from a post is meant to be found — but autosaves are, because they hold edits nobody has saved yet. And the re-check before deletion is not atomic: a reference written in the instant between the re-check and the deletion is not seen. That window is a fraction of a second; the recent-upload grace period covers the realistic case (a file placed in the editor before its post is saved), and MEDIA_TRASH covers the rest. So: if a plugin on your site stores media in its own tables, check what it holds before deleting — and add define( 'MEDIA_TRASH', true ); (see Installation) so a deletion can be undone.

Does it delete unused images?

Yes, once the scan has shown that nothing on the site uses them. Images, documents, audio and video are all judged the same way: every place a reference can live is read, the evidence is listed per file, and a file with no reference anywhere is offered for deletion. Deleting removes the file and every resized copy WordPress made of it, or moves the entry to the media trash when MEDIA_TRASH is on. Nothing is deleted until you click a delete action, and each file is re-checked in the instant before it goes.

Is it safe to bulk delete unattached media?

No. Deleting on the strength of the Unattached filter deletes files that are in use. Media deletion in WordPress is permanent unless MEDIA_TRASH is enabled, so the references have to be searched for before anything is removed. Run the full scan first and bulk delete from the unused list instead: every file on it has been checked everywhere a reference can hide, and is checked once more before it goes.

How is this different from the "Unattached" filter?

Unattached only means the file was not uploaded from inside a post editor. WordPress records the post you were editing at upload time and nothing else, so a file used in a custom field, a page builder, a widget or a theme setting is shown as unattached while being displayed on the site every day. This plugin reads the places a file is actually referenced from: post content, custom fields (ACF included), featured images, galleries, options and theme mods, widgets, term and user meta, comments and raw URLs. "Uploaded to" is shown as information but never counts as usage.

How long does a full scan take?

Longer than a scanner that only looks at the "Uploaded to" column, because it looks everywhere else as well. On a large library the first full scan is measured in hours, not minutes. It runs in batches from the Media → Usage screen, each batch stops before the PHP time limit and the next one resumes from the last completed file, so the scan always makes progress and can be stopped and picked up later. Nothing runs on a schedule — a scan happens when you start one.

Does a file referenced from the trash get deleted?

No. A trashed post or comment can be restored, so a reference from one keeps the file — it is reported as a possible reference rather than a confirmed one, and possible still counts as used.

What about files that are themselves in the media trash?

A file whose every library entry is in the trash is listed in its own "In trash" section under the unused list, and can be erased from there once the scan has found every entry unused — it never joins the unused list or its count, and a copy still in use is held back there too.

Does it work with multisite?

Per site, yes. Cross-site references (another site embedding this site's file URL) are not detected.

Does it delete anything by itself?

Never. Scanning only reads and caches results. Deletion happens exclusively when you click a delete action, after re-verification. Opening the page deletes nothing.

Where do I get help?

Write to the address on freshet.studio/support. Support is email, read by the person who wrote the plugin — say which plugin, which version, and what you saw, and a screenshot covers most of that in one go. Questions here in the WordPress.org support forum are read too.

更新日志:

1.1.0 1.0.10 1.0.9 1.0.8 1.0.7 1.0.6 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 1.0.0