Hi there, I’m glad to share my third plugin: Obsidian paste image rename.
This plugin is inspired by Zettlr, Zettlr shows a prompt that allows the user to rename the image, this is a great help if you want your images to be named and organized clearly.
Paste image rename plugin not only implements Zettlr’s feature, but also allows you to customize how the image name would be generated, and eventually free you from the hassle by automatically renaming the image according to the rules.
Installation
The plugin has been added to community plugins, you can now search “Paste image rename” to install it.
Currently this plugin is in review, but you can take a try by either way below:
- Manually download the latest release from GitHub and extract the files in
$YOUR_VAULT/.obsidian/plugins/obsidian-paste-image-rename
. - Use BRAT plugin
How to use
Basic usage
After installing the plugin, you can just paste an image to any document, and the rename prompt will display:
By typing the new name and clicking “Rename” (or just press enter), the image will be renamed and the internal link will be replaced to the new name.
If you set “Image name pattern” to {{fileName}}
(it’s the default behavior after 1.2.0),
“New name” will be generated as the name of the active file.
Set imageNameKey
frontmatter
While adding a lot of images to one document, people possibly want the images to be named in the same format. That’s where imageNameKey
is helpful.
First set a value for imageNameKey
in frontmatter:
---
imageNameKey: my-blog
---
Then paste an image, you will notice that the “New name” has already been generated as “my-blog”, which is exactly the value of imageNameKey
:
You can change the pattern for new name generating by updating the “Image name pattern” value in settings.
For detailed explanation, and other features such as auto renaming, please refer to Settings.
Add prefix/suffix to duplicated names
The plugin will always try to add a prefix/suffix if there’s a file of the same name.
Let’s continue from the last section and paste the second image, the prompt will still show the new name as “my-blog”, now if we just click “Rename”, the file will be renamed as “my-blog-1.png”, not “my-blog.png”:
The -1
suffix is generated according to the default settings:
- Because “Duplicate number at start” is false, suffix is used rather than prefix
- “Duplicate number delimiter”
-
is put before the number1
If we paste the third image without editing the “New name” input, its name will be “my-blog-2.png”, the number is increased according to the largest number of “my-blog-?.png” in the attachment directory.
This feature is especially powerful if you enable “Auto rename” in settings, you can just add new images without thinking, and they will be renamed sequentially by the pattern and imageNameKey
set.
Have fun.