Coder Social home page Coder Social logo

ozntel / oz-clear-unused-images-obsidian Goto Github PK

View Code? Open in Web Editor NEW
167.0 167.0 11.0 502 KB

Obsidian plugin to clear the images that are not used in note files anymore

JavaScript 3.42% TypeScript 95.74% CSS 0.84%
clean-vault clear images obsidian obsidian-md obsidian-plugin

oz-clear-unused-images-obsidian's Introduction

Hi, I'm Ozan

HRIS Manager and Passionate Programmer building Websites, Plugins and Various Automatization Scripts.

You can visit 🏠 My Personal Page if you want to find out more.

Things I code with

Javascript TypeScript React React Native html5 CSS3 Bootstrap Python Django Django Rest VBA Markdown Prettier git Github npm Visual Studio Code Docker AWS Firebase Apache Ionic

My open source projects

🎁 Projects ⭐ Stars 📚 Forks 🛎 Issues
Obsidian File Tree Alternative Plugin Stars Forks Issues
Obsidian Image in Editor Plugin Stars Forks Issues
Obsidian Link Converter Plugin Stars Forks Issues
Obsidian Clear Unused Images Plugin Stars Forks Issues
Obsidian File Explorer Note Count Plugin Stars Forks Issues
Obsidian Oz Calendar Stars Forks Issues
Obsidian Msg Handler Stars Forks Issues
Django Blog Application Stars Forks Issues
Django CV Builder Stars Forks Issues

All My Repos are Below 👇

Feel free to give Your Suggestions, Issues or PRs 🌍

Where to find me

Medium LinkedIn Github

oz-clear-unused-images-obsidian's People

Contributors

ozntel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

oz-clear-unused-images-obsidian's Issues

Version for VsCode

I need to clear unused pics and VsCode is more frefuently used in my case. Do you have a version for that? Thanks

[Suggestion] Run the script each x times

Hello! Great plug-in! It helps me to clean around 100 images (yup... Copy paste 🙈)

I was wondering if it's possible to add an option to :

  • Run each x time, like each 2 days, each 2 hours...
  • Run when obsidian is open, like an autoclean.

Thank you anyway! ✨

Script deletes used images if file extensions are capitals e.g. .JPG

This plugin deletes images that are linked.

I was able to restore them from version control, so I'm OK... but still...

Environment

  • macOS 10.15.7
  • Obsidian v0.12.19
  • Clear Unused Images 1.0.3

Demonstration

Here are some existing links to images:

%% Zoottelkeeper: Beginning of the autogenerated index file list  %%
📄 [[Clare/Humour and interesting things/IMG_0439 - Quantum Engagement - Jim Al-Khalili.PNG|IMG_0439 - Quantum Engagement - Jim Al-Khalili.PNG]]
📄 [[Clare/Humour and interesting things/IMG_0441 - Traditionalist Cartoon.JPG|IMG_0441 - Traditionalist Cartoon.JPG]]
📄 [[Clare/Humour and interesting things/IMG_0591 - Sufficiently Advanced Stupidity.PNG|IMG_0591 - Sufficiently Advanced Stupidity.PNG]]
📄 [[Clare/Humour and interesting things/IMG_0625 - REDACTED.PNG|IMG_0625 - REDACTED.PNG]]
📄 [[Clare/Humour and interesting things/IMG_2030 - Blame the Straight People.JPG|IMG_2030 - Blame the Straight People.JPG]]
%% Zoottelkeeper: End of the autogenerated index file list  %%
# Amusing Images

![[IMG_0439 - Quantum Engagement - Jim Al-Khalili.PNG]]

![[IMG_0441 - Traditionalist Cartoon.JPG]]

![[IMG_0591 - Sufficiently Advanced Stupidity.PNG]]

![[IMG_0625 - REDACTED.PNG]]

![[IMG_2030 - Blame the Straight People.JPG]]

When I run "Clear unused images" I get this output, showing me that all those linked images were deleted:

image

MAJOR breaking issue: used images in codeblocks get deleted!

I frequently use (admonition) codeblocks to manage images. For example image grids to more efficiently arrange images or in admonition codeblocks for warnings or quotes.
Also "Obisdian Columns" uses codeblocks to display multiple columns.

These images DO get deleted when running the "clear unused images" command.
Luckily I had a backup to restore all the lost images.

Since codeblocks are used very frequently to add additional functionality to Obisdian (like Grids, Columns and so on), this is (obviously) a major breaking issue.

STEPS TO REPRODUCE:

  1. have "Admonition" plugin installed (it might also happen with "normal" codeblocks, but I havent tested since restoring all images always is quite some effort)
  2. create an admonition codeblock
  3. add an image to the codeblock (see example below)
  4. run "clear unused images" command

EXPECTED RESULT

  • only unused images should get deleted

ACTUAL RESULT

  • images that are still in use in codeblock gets deleted

EXAMPLE

```ad-warning
![[test_image.png]]
```

Folder exclusion issue

Hi,
I have a folder with images that I want to exclude from being deleted if not used.
In this folder I have 2 images used for banner, and one of them is not used

image

KnowledgeBase is the name of my Obsidian Vault
Folder is under C:/path/KnowledgeBase/banner
Under "Clear Unused Images" plugin I've set a "Excluded Folder Full Paths" to: KnowledgeBase/banner

image

When I hit "clear Unused images", the used image is not deleted, but the unused file is deleted.

image

Did I miss something in the configuration of the plugin? or is it a bug?
Obsidian Version: 0.12.16 / Clear Unused Images plugin version 1.0.3

Thanks for the support

Hello! Thank you for the great extension! Here I have an idea, it would be better to add a command to delete only the unused images of the currently opened file, so that the user experience will be more friendly and user-friendly.

Hello! Thank you for the great extension! Here I have an idea, it would be better to add a command to delete only the unused images of the currently opened file, so that the user experience will be more friendly and user-friendly.
And allow the user to manually trigger the command to delete the file instead of forcing it to be deleted automatically.

Where do deleted images go?

iyi bayramlar...great work on this plugin @ozntel !

I am wondering, where do the deleted images go - do they get immediately destroyed, or end up in Vault trash etc?

[FR] Create document listing the unused images

A new option for dealing with the unused images:

  • Create a document listing all of the unused images rather than trashing them.

This is probably a nice feature for someone new to the code base to implement, if they know TypeScript. I don't know TypeScript. 😢

My use case:

I've migrated my vault from Joplin, and I'm paranoid about having lost notes, broken image references, etc. I'd like to see what images I've got that haven't been properly referenced by a note.

Implementation ideas:

  • Create _Unused Images.md in the vault root. Append to existing file? or offer to overwrite?
  • Really simple, sorted list like:
# Unused Images

![image_name1.png](path/to/image_name1.png)

![image_name2.png](path/to/image_name2.png)

...

![image_namen.png](path/to/image_namen.png)

[FR] delete images only in all folders with specific name, e.g. "assets"

I put all the images I insert into Notes in a subfolder called "ASSETS". This folder exists in every directory. Furthermore, there are many images that stand completely alone, for example because they belong to the project and stand alone.
It would help me a lot if your plugin would check only all those images that are in the folders with special names (for me "ASSETS").

[FR] Conflict with Annotator

Hello, I some times like to use Annotator to annotate my pdf file. However, oz-clear-unused-images-obsidian didn't recognize the file name in annotate. Then it delete the pdf file there. This is not the result I wang to have. Can you add the support to recognize the file in annotate?

Plugin deletes JS-Files in template folder

Plugin deletes JS-Files in template folder which are used by a plugin. I can exclude the template folder, but a plugin deleting images should not delete anything else.

image

Could you please support .webp file?

Hello, I have downloaded and saved many webp image files from the internet in md file. However, it appears that the plugin is unable to recognize this file format. I am hoping that support for webp images can be added. Thank you.

FR: exclude files by specific name

can this plugin support to exclude files by specific name?
as Im using Make.md plugin that creates sqlite files like "context.mdb" in every folder.
I need those file to have like board view of my folder files, but this plugin will delete them.

can you support to exclude file by specific name? or even better, support regex like "*.mdb"

Deletes non-image files, can't configure Attachments folder

Scenario

Under the assumption this plugin only deletes images, one could remove important, external assets, like done below:
image
My specific usecase involves dynamic plotting within notes, which then requires me to have d3.js in the vault's root for the Plotly plugin. This file is also outside the configured Attachments folder, which I naively assumed would be the only target of this plugin, and which is not currently configurable to become the only target¹.

¹ Obsidian attachments folders are always inside the Vault, so the "Exclude Full Paths" option is not applicable for trying to ignore anything outside said folder. Excluding path/to/vault also excludes path/to/vault/attachments. The "Exclude subfolders" is similarly not applicable, since it's the parents of Attachments that need to be ignored.

Possible Solutions

  • Check file extensions before clearing, or change the whole premise of the plugin to be "Clear Files" instead of "Clear Images"
  • Have either an "Include-only" path setting, or a toggle for "Only clear within configured Attachments folder"

[Suggestion] Exclude folder

Hello!

I found a little problem : I have a gallery of images references for writing, and the plugin delete it because the plugin gallery doesn't work as link.

It will be good to exclude folder.

[FR] Have a "test" option in settings

That shows what would be deleted without doing the delete.

I had a typo entering the exclude folder path. When running "clear unused attachments", a whole folder tree (mix of files and subfolders) was deleted. "Move to Obsidian trash" discards the folder structure.

An option to copy the log to the clipboard would also be handy.

[Enhancement] Only scan certain folder to delete and exclude also subfolder inside folder

Hi there, I think it's really inconvenient to add a folder to the exclude list every time I create one.
I suggest to add for example:
Path* = Excludes every subfolder and sub-subfolder inside the Path

I also think that it's a good idea to only scan a certain folder when deleting, since some people (me) only put images/attachments inside a folder, and permanent/important images inside another

I hope that makes sense lol
thank you!

[FR] Exclude seems to need escapes for some characters.

I found that having a Path like Something+/Files needs to be added as Something\+/Files to avoid deletion of the images.

P.S.: I actually think that the plugin needs to be changed so that it presents what it wants to delete and to add exceptions there. But from looking at the open issues, I guess the author does not really want to invest this time.

@ozntel I just want to ask if you are continuing to develop and/or will accept PRs for this repo?

Could it just show log when delete file?

When I use the command, Clear Unused Images, to delete image, it always displays the log. However, sometimes it doesn't delete the file and I don't want to see it.

[BUG] Deleted images by mistake

It has deleted images that had been used in a file。

File path:
vault/中文/article.md

Image formation in the file:
![[assets/image-20220831182103.png]]

Image path:
vault/中文/assets

Clear Unused Images - Logs:

[+] 07/09/2022, 14:23:10: Clearing started.
[+] Moved to System Trash: 中文/assets/image-20220831182103.png
[+]1 image (s) in total deleted.
[+1 07/09/2022, 14:23:10: Clearing completed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.