puhhh1k downloadsFork of oz-clear-unused-images for clearing unused images from vaults.
Clear Unused Images Plus is an Obsidian plugin for finding and deleting images that are no longer referenced in your vault. It scans markdown notes, supported frontmatter references, canvas files, and attachment links, then compares those references against image files in the vault.
Use it when attachments accumulate over time and you want cleanup to follow Obsidian's own deletion behavior instead of bypassing your vault settings.
This project is a maintained fork of oz-clear-unused-images. The current fork is maintained by Aleksei B. The original plugin author is Ozan.
See CHANGELOG.md for release history.


Requirements: Obsidian 1.8.10 or newer.
Clear Unused Images Plus..trash.Clear unused images from the Command Palette.Deleted files and folders follow Obsidian's own file deletion preference:
.trash inside the vault.The plugin provides three cleanup commands:
Clear unused images checks only image files. It is limited to jpg, jpeg, png, gif, svg, bmp, and webp.Clear unused attachments checks all non-note attachments in the vault, not just images. This can include PDFs, audio, video, archives, and other non-markdown files.Clear unused folders removes empty folders recursively, starting with the deepest folders first. It follows Obsidian's file deletion preference and keeps folders under excluded folder paths.Use Clear unused images for routine image cleanup. Use Clear unused attachments more carefully because it has a wider scope and can delete any attachment the plugin cannot find referenced in notes, canvas files, or supported frontmatter references. The attachment cleanup flow shows a review modal before deletion. Use Clear unused folders after file cleanup if you want to remove empty folder structure left behind, or enable Clear empty folders after image cleanup to do that automatically.
You can run cleanup from the ribbon icon or from the Command Palette with Ctrl/Cmd + P.
![]()

If Delete Logs is enabled, the plugin shows a modal with information about deleted files:

If all images are still used, the plugin reports that nothing was deleted:

Enable Clean Images On Vault Load to run image cleanup once after the vault layout is ready:

Clear unused attachments.Enable Clean Images Every X Minutes to run recurring image cleanup while Obsidian stays open:

Enable Clear empty folders after image cleanup to remove folders that become empty after unused image cleanup deletes images:

Clear unused images, Clean Images On Vault Load, and Clean Images Every X Minutes.Clear unused attachments.Use excluded folders to prevent cleanup from deleting files under specific vault paths. Separate multiple folders with commas and provide full paths inside the vault.

Turn on Exclude subfolders if the excluded paths should protect every child folder too:

Use Excluded file extensions to keep specific file types regardless of whether they are linked from any note. Separate extensions with commas; matching is case insensitive and a leading dot is optional (pdf, .mp4 both work). This is handy when you store files in the vault but never attach them — for example PDFs opened with Obsidian's PDF viewer.
npm ci
npm run dev
npm test
npm run build
npm ci installs the locked dependency set used by CI and release builds.npm install is fine when you intentionally update dependencies.npm run dev builds in watch mode.npm test runs the Vitest suite.npm run build creates the production main.js bundle.npm run build, refresh the installed vault copy before manual testing:cp main.js .obsidian/plugins/clear-unused-images-plus/main.js
cp styles.css .obsidian/plugins/clear-unused-images-plus/styles.css
git diff --no-index -- main.js .obsidian/plugins/clear-unused-images-plus/main.js
git diff --no-index -- styles.css .obsidian/plugins/clear-unused-images-plus/styles.css
No output means the local Obsidian plugin copy is in sync.
GitHub Releases are published by GitHub Actions when a version tag is pushed.
package.json, package-lock.json, manifest.json, versions.json, and CHANGELOG.md.npm run lint, npm test, and npm run build.main.js and styles.css into .obsidian/plugins/clear-unused-images-plus/ for manual Obsidian verification.main, and merge it.main:git tag -s -m "X.Y.Z" X.Y.Z HEAD
git push origin main
git push origin X.Y.Z
The release workflow verifies that the tag version matches package.json, manifest.json, and versions.json, runs the release audit, rebuilds main.js, creates GitHub artifact attestations, and uploads manifest.json, main.js, and styles.css as release assets. Obsidian requires the GitHub release tag to match manifest.json exactly, so use 1.0.0, not v1.0.0.
src/main.ts - Obsidian plugin entry pointsrc/util.ts - vault scanning and cleanup orchestrationsrc/linkDetector.ts - markdown and wikilink reference detectionsrc/referenceUtils.ts - pure reference and path helperssrc/folderCleanup.ts - empty-folder cleanup behaviortests/ - regression coverage for cleanup, references, settings, and schedulingdocs/assets/ - screenshot assets used in this READMEstyles.css - plugin stylesmain.js - built plugin bundleTests use vitest, with jsdom available through per-file @vitest-environment jsdom comments when DOM coverage is needed. The most important coverage is around markdown links, wikilinks, frontmatter references, canvas parsing, excluded folders, delete failure handling, and startup or periodic cleanup scheduling. Run npm run lint and npm test before publishing changes.
When fixing safety bugs, add a focused regression first, verify it fails, then fix the implementation. For deletion or exclusion bugs, cover both helper behavior and cleanup-flow results.
main.js is generated; do not edit it by hand..obsidian/plugins/clear-unused-images-plus/ is for testing only and is not part of the Git repository.