vscode-front-matter icon indicating copy to clipboard operation
vscode-front-matter copied to clipboard

Enhancement: Indicate if a media file is referenced in any other content/layout files.

Open zivbk1 opened this issue 2 years ago • 3 comments

Over time media files in the 'static' folder become obsolete and are not referenced anywhere in any content files, layout files, etc. When this happens it would be good to flag these orphaned/unreferenced files and delete them from the repository.

Describe the solution you'd like I am not sure the best way to do this, but I was thinking it might be a feature of the media gallery to somehow search the filesystem for all references by filename, or indicate how many times the filename is referenced in content/layout files.

Describe alternatives you've considered Right now I can use the VS Code search tool to search for the filename and see if I get any hits. But this is a very tedious process and seems ripe for a helper tool.

zivbk1 avatar Apr 10 '22 18:04 zivbk1

@zivbk1, I think this could be a useful functionality. Not sure how to present it yet, but we'll figure something out! Again, great suggestion 🙏

estruyf avatar Apr 11 '22 07:04 estruyf

I was thinking about this again, and a quick check might be to text search through all 'content' folders/files for the filename of the asset in the gallery, and if nothing hits, then mark that in the DB so that we can sort/filter media that is unreferenced in content.

bwklein avatar May 23 '22 16:05 bwklein

I wonder if it's possible to use the mediaDb.json file for this - automatically associating media files with documents they're added to when added through the image snippets, possibly being able to use a command/script to inspect the content and associate the media files.

In the meantime, I think it might be possible to write a sample script and use/document that.

michaeltlombardi avatar Oct 08 '22 05:10 michaeltlombardi