Description
Tehnika Media Exporter & Cleaner gives you two jobs in one screen. Export the media that belongs to a migration, a backup or a hand-over — and clean up the files nothing on the site uses any more.
Both tools share the same filter engine. An export and a cleanup can start from the same selection, which makes the safe workflow obvious: export a backup, then clean the original.
Every job runs as a sequence of short server batches instead of one long request, so PHP time limits and memory limits stop being a problem. Finished archives are streamed to your browser in chunks and never loaded into PHP memory.
Export
Three ways to scope an export
- The whole library — every attachment, narrowed by file type, uploader and date range.
- Media used by specific content — start from posts, pages or any public custom post type, narrow them by category, tag and post status, then follow the featured image, the files uploaded to the post, the images embedded in its body, or any combination.
- Unreferenced media — attachments that no post, page, featured image, gallery or site option points at.
Five output formats
- ZIP archive — the actual files, with an optional folder structure (flat, by upload date, or by media type), an optional
manifest.csvinside the archive, and optional inclusion of the generated thumbnail/medium/large versions. Duplicate file names are prefixed with their attachment ID so nothing is silently overwritten. - URL list — one direct file URL per line, ready for
wget -iorcurl. - CSV manifest — a spreadsheet of every file: ID, name, URL, MIME type, size, dimensions, upload date, author and parent post.
- JSON manifest — the same data for scripts and migrations.
- WXR XML — a WordPress import file containing the selected attachments and their metadata.
Clean
The Clean tab uses the same scope filters, then adds the decisions that matter before anything is removed.
- Unreferenced media first. The default scope finds attachments that no post, page, featured image, gallery, site icon or site logo references.
- A filtered selection. Retire old documents, oversized archives or everything uploaded by a former contributor — by file type, uploader and date.
- Media used by specific content. Remove the files that belong to a section you are retiring, following featured images, attached files and inline embeds.
- Trash by default. The safe action is a real WordPress trash: the files stay on disk and can be restored from Media → Trash.
- Permanent deletion is opt-in. Off by default, limited to administrators, and enabled on the Settings tab. The confirmation requires you to type
DELETE. - Review before you commit. Count, total size, per-type breakdown and sample file names are shown in a confirmation dialog before the first attachment is touched.
- Safety window. Media uploaded in the last few days is always skipped, so a cleanup cannot remove work that was just added by mistake.
- Exclusion list. Protect specific attachment IDs, and use the
tme_clean_protected_idsfilter to protect media that plugins store in their own tables. - CSV audit log. Every cleanup writes a log with the ID, file name, URL, MIME type, size, upload date, author, parent post and action. Download it from the Clean tab or the Log tab.
- Backup-first workflow. One button copies the exact cleanup selection to the export screen as a ZIP, so you can keep a copy before removing anything.
- Batched and resumable. A six-figure cleanup runs in short requests with a live progress bar instead of timing out.
Accurate usage detection
Most tools look for a single pattern. This one recognises:
- Gutenberg block attributes —
wp:image,wp:gallery,wp:cover,wp:media-textand anything usingid,ids,mediaIdorattachmentId - Classic editor markup —
wp-image-123classes,wp-att-123links andattachment_123caption IDs - Shortcodes that carry IDs —
[gallery],[playlist],[album],[slideshow],[carousel] - Query strings such as
?attachment_id=123 - With deep scan enabled: raw
src,srcsetand lazy-load URLs, resolved back to attachment IDs through a bulk uploads index
Built for real libraries
- Batched, resumable jobs. Progress is stored on the server, so a huge export or cleanup survives a page reload.
- Honest progress. A live percentage based on bytes and file counts, with the number of files processed, skipped or rejected.
- Preview before you commit. Count, total size and a breakdown by file type, without building or deleting anything.
- Searchable pickers. Category, tag and uploader fields search through AJAX, so a site with 20,000 terms still opens instantly.
- Cached analytics. Library breakdown, uploads per month, top uploaders and an unreferenced-media scan.
- WP-CLI.
wp tme export,wp tme cleanandwp tme unusedrun the same engine from the command line.
About the Author
Maintained by Tehnika, a creative digital agency working with remote teams and WordPress. We built this to solve our own migration headaches and decided to share it.
Use cases
- Migrating content — move selected posts to another site together with the images they actually use.
- Backups — download everything uploaded by a specific author last month, as a ZIP.
- Auditing — get a CSV of every document in a category, with sizes and parent posts.
- Housekeeping — find and trash media nothing references any more, with an audit log to prove what was removed.
- Storage recovery — retire old PDFs, archives and oversized images without touching the current season.
- Automation — drive exports and dry-run cleanups from WP-CLI in a deployment or archiving script.
Installation
- Upload the plugin files to
/wp-content/plugins/tehnika-media-exporter, or install it through the WordPress plugins screen. - Activate the plugin.
- Go to Tools → Tehnika Media.
The working folder lives at wp-content/uploads/tme-exports/. It is created automatically and blocked from direct web access; downloads and cleanup logs always go through WordPress so the permission check cannot be bypassed.
FAQ
Does this plugin require any server extensions?
ZIP export needs the PHP zip extension. Everything else — URL list, CSV, JSON, XML and the cleaner — works without it. If ZIP is unavailable the plugin tells you so on its screen and greys the option out.
How large an export or cleanup can it handle?
Neither job holds a whole archive or file list in PHP memory, and both work in small batches, so they are bounded by disk space rather than by memory or execution limits. If a host is unusually strict, lower Files per batch and Seconds per batch on the Settings tab; the job simply takes more requests.
Is anything deleted by this plugin?
Only when you explicitly run a cleanup and confirm it. Exports are read-only. Cleanup defaults to Move to trash, which is reversible. Delete permanently is off by default, limited to administrators, and requires typing DELETE in the confirmation dialog.
Can I undo a cleanup?
Yes, if you chose Move to trash. WordPress keeps trashed attachments and their files until the trash is emptied; restore them from Media → Trash. Permanent deletion cannot be undone, which is why it is opt-in and every run produces a CSV audit log.
What if my site has disabled the WordPress trash?
If your site sets EMPTY_TRASH_DAYS to 0, WordPress does not keep trashed media. The cleaner detects this and refuses to run Move to trash, because core would delete the files permanently. Enable trash retention or use permanent deletion explicitly.
What is in the cleanup audit log?
One row per attachment: ID, file name, URL, MIME type, size on disk, upload date, author ID, parent post, the action taken and a timestamp. It is downloadable from the Clean tab immediately after a run and from the Log tab later.
What counts as “unreferenced” media?
An attachment with no parent post, no featured-image or gallery reference, no inline reference in post content, and no reference from the site icon, site logo or theme logo. Page builders and plugins that store IDs in their own tables need the tme_clean_protected_ids filter or the exclusion list.
Are unpublished posts included in the usage scan?
By default only published content is scanned for references, so drafts and scheduled posts do not leak media into an export. Add those statuses explicitly in the post status filter when you want them.
Where do finished exports go?
Into a protected folder inside your uploads directory, for as long as you configure (24 hours by default). They can be downloaded again from Recent exports, and are then swept automatically. Nothing is left behind after that.
What happens when I uninstall it?
Nothing is removed unless you tick “Delete settings, log, presets and the export folder when the plugin is uninstalled” on the Settings tab. That is off by default.
Screenshots







Changelog
2.1.1
- Fix: hardened the Clean tab against a stale cached admin script. The page now says so instead of silently doing nothing.
- Fix: “Review in the cleaner” is a real hash link and cannot send you to the Export tab when an old script is cached.
- Fix: arriving from the Library scan now runs the clean preview automatically instead of just switching tabs.
- Fix: clean preview now works for users who can access the screen but cannot delete media. The cleanup action stays disabled and the server still enforces the delete capability.
- Fix: preview and cleanup errors are shown inline in the Clean tab, not only in a short-lived toast.
- Fix: the progress dialog now offers Close after a completed job, and Cancel now also stops a running cleanup.
- Improved: admin notifications appear bottom-left, so they cannot cover the Clean tab action buttons.
- Improved: admin CSS/JS URLs are cache-busted with the file modification time, so updates cannot keep serving old assets.
- Improved: clean preview shows a scanning status on large libraries and caches the result for five minutes.
- Improved: asset loading is checked at runtime; if the cleaner script did not initialize, the tab explains how to clear the cache.
2.1.0
- New: Clean tab — clean media by usage, file type, uploader, date or the content it belongs to.
- New: Move to trash as the default cleanup action. Trashed attachments keep their files and can be restored from Media → Trash.
- New: optional permanent deletion, disabled by default, limited to administrators and protected by a type-DELETE confirmation.
- New: confirmation dialog showing the exact count, total size, per-type breakdown and sample file names before a cleanup starts.
- New: a safety window that always skips media uploaded in the last few days.
- New: protection for the site icon, site logo and theme logo, plus an exclusion list and the
tme_clean_protected_idsfilter. - New: a CSV audit log for every cleanup, downloadable from the Clean tab and the Log tab.
- New: Back up this selection first copies the cleanup selection to the export screen as a ZIP.
- New: cleanup jobs run in resumable server-side batches with a live progress bar.
- New: WP-CLI
wp tme cleanwith a dry run by default,--yes,--action,--grace-daysand--exclude. - New: Settings for the default cleanup action, the safety window and whether permanent deletion is allowed.
- New: the plugin is now called Tehnika Media Exporter & Cleaner, with a redesigned banner and fresh screenshots.
- Improved: the Log tab separates exports from cleanups and links each cleanup to its audit log.
- Improved: “Move to trash” is refused on sites where
EMPTY_TRASH_DAYSis 0, because WordPress would delete the files permanently instead. - Improved: the library cleanup audit now hands its selection straight to the Clean tab.
- Improved: the plugin screen, menu label, notices, help and readme all use the new name.
- Improved: preview caches are invalidated after a cleanup, so counts never go stale.
- Fixed: ZIP folder layout validation now accepts the
mimelayout instead of a non-existentpost_typevalue.
2.0.0
- New: exports now run in resumable server-side batches, so large libraries no longer hit PHP time or memory limits.
- New: finished archives are streamed to the browser in 256 KB chunks instead of being loaded into PHP memory. This fixes a hard failure on libraries where the archive exceeded the memory limit.
- New: Preview selection reports the file count, total size and a per-type breakdown before anything is built.
- New: CSV and JSON manifest formats.
- New: Unreferenced media scope for cleanup audits.
- New: saveable filter presets.
- New: WP-CLI commands —
wp tme export,wp tme stats,wp tme unused. - New: ZIP folder structures (flat, by upload date, by media type) and an optional
manifest.csvinside the archive. - New: option to include generated thumbnail, medium and large files alongside the originals.
- New: export log, and stored archives that can be downloaded again from Recent exports.
- New: filterable term and uploader pickers that search through AJAX, so large sites open instantly.
- New: cached library analytics with a budgeted uploads-folder measurement.
- New:
tme_source_post_args,tme_referenced_media_idsandtme_attachment_pathfilters for developers. - Performance: featured images are resolved with one indexed query per batch instead of one query per post.
- Performance: post bodies are fetched as
IDandpost_contentonly, instead of loading complete post objects to run a regular expression over one column. - Performance: every
IN (…)clause is chunked, so six-figure libraries cannot overflow the query string. - Performance: each batch primes the post, meta and user caches once, removing per-item database hits from every writer.
- Performance: the analytic counts run as single queries; the directory measurement is time-budgeted and degrades to a partial figure instead of hanging.
- Improved: embedded-media detection now understands Gutenberg block attributes,
[gallery]/[playlist]/[slideshow]shortcodes, classic caption IDs and?attachment_id=query strings. - Improved: deep scan resolves
src/srcset/lazy-load URLs to attachments through a bulk uploads index rather than one lookup per URL. - Improved: duplicate file names inside an archive are prefixed with their attachment ID instead of overwriting each other.
- Improved: the interface is fully keyboard navigable, uses ARIA tab and combobox patterns, announces progress to screen readers, and replaces
alert()with inline toasts. - Fixed: the readme listed
tehnika.mkas a contributor, but that is not a WordPress.org account, so the plugin page showed no author. - Fixed: the screenshot asset was uploaded as
screenshots-1.png, which WordPress.org does not recognise. - Tweak: requires WordPress 5.6 and PHP 7.4.
- Tweak: the export folder is created with
index.phpand.htaccessguards and is never web-accessible.
1.0.8
- Enhancement: Complete UI overhaul with a modern, card-based interface.
- Enhancement: Improved user experience with clear selection states and better layout.
1.0.7
- Fix: Replaced deprecated
seems_utf8function withwp_is_valid_utf8to ensure future compatibility.
1.0.6
- Fix: Removed dependency on core
export.phpfile to comply with WordPress Plugin Guidelines. - Fix: Moved JavaScript and CSS to external files and implemented
wp_enqueue_scriptsfor better performance and security. - Tweak: Updated XML generation to use local CDATA formatting.
1.0.5
- Maintenance release.
1.0.4
- New: Added progress bar and loading overlay to improve UX during large exports.
- Fix: Resolved security warning regarding sanitization of post type input arrays.
- Tweak: Improved internal file handling for ZIP generation.
1.0.3
- Added XML export format support.
1.0.0
- Initial release.
