obsidian-paste-image-rename
obsidian-paste-image-rename copied to clipboard
add {{hex}} and {{uuid}}
resolves #22
we would obviously need to add more documentation, but it does the job for now.
Thanks for the PR, I see how this works. Surely UUID is a great idea, but I doubt whether using 4 random generated hex string conforms the RFC standard.
As to the hex and hexNs, I suggest changing them to hash and shortHash, because random hex string is not guaranted to be unique, which may cause collision with other files. hash and shortHash are borrowed from Git, which use SHA-1 hex digest to represent a commit. For this plugin, we can generate the SHA1 hex for image file based on its content.
Ah, OK. I see your suggestion.
For {{hex}}, This is the convention I use for my vault. I use it so that each entity can be mapped in an sRGB colorspace, which I use for determining meta colors. I also figured that the chances of collision are improbable, considering that even if I have 1K images, the case of collision is 0.00625%.
But I know — this is purely my opinion, and I agree that the chance of collision is comparably way higher than UUIDs.
What if we add hash and shortHash and keep the {{hex}} options as well? We can
- add a warning that the chance of collision will be high
- or make a loop that retries when the entity already exists
I am already using a variant of your extension that supports {{hex}}, and it satisfies my needs, so if you do not like it, I don't mind removing the option.
Hi @anaclumos , it's been a long time, but I finally got myself back to this project.
My suggestions are:
- rename
hextorandomHexto clarify it. - indicating the size of the hex string by appending the number with a colon, e.g.
{{randomHex:8}}. A similar format is seen in{{DATE:YYYYMMDD}}, which gives more flexibility and avoids redundancy. hashandshortHashare omitted until anyone wants them.
After these simple changes are made, we'll be good to go!
Apologies for the late reply! I was having trouble with my Obsidian - Cloudflare setup and cannot confirm it immediately. If this PR works for you, please feel free to merge it!
Thank you so much for your consideration and attention to detail. It was a brilliant experience collaborating with you! ❤️🔥