If you search help about the Settings you can check the documentation.
This plugin for Obsidian, stores remote attachments (currently only images) locally inside the vault.
The note is not modified by default, this way even outside of the vault the attachments keep working with the remotes URL.
Note: The attachments can be "archived" instead, which makes the note reference the local file, check
Update attachment link?.
When the attachment is rendered in a note, the local version is used instead of the remote working as a local cache.
Note: The cached attachments can be deleted any time to free up disk space.
In detail, during the Obsidian render process, when an img is found:
img element to use the cached file inside the vault.Based on the Obsidian supported file-formats the next attachments formats are been cached:
.avif, .bmp, .gif, .jpeg, .jpg, .png, .svg, .webp.flac, .m4a, .mp3, .ogg, .wav, .webm, .3gp.mkv, .mov, .mp4, .ogv, .webm.pdfYou can activate this plugin within Obsidian by doing the following:
You can activate this plugin, building from source by doing the following:
pnpm build:dist or an equivalent.dist folder to your vault, the path should look like <path-to-your-vault>/.obsidian/plugins/attachments-cacheThis plugin is provided to everyone for free, however if you would like to say thanks or help support continued development, feel free to send a little through the following method:
The plugin is not on active development, new features or changes are developed when there is an oportunity. But issues and bugs will have especial priority.
An API AttachmentsCache is exposed globally for easy integration.
For usage inside a plugin the methods isPluginEnabled and getAPI are exposed from an npm package named @luis.bs/obsidian-attachments-cache
pnpm add @luis.bs/obsidian-attachments-cache
On other environments where the package can not be used as a dependency, the API is attach to the global window object. The next declare can be used for development:
declare namespace AttachmentsCache {
/** Determine whether the attachment matches a **short-term** storage rule. */
isCacheable(remote: string, notepath: string, frontmatter?: unknown): boolean
/** Determine whether the attachment matches a **long-term** storage rule. */
isArchivable(remote: string, notepath: string, frontmatter?: unknown): boolean
/** Download the attachment and get the localpath. */
cache(remote: string, notepath: string, frontmatter?: unknown): Promise<string | undefined>
/** Download the attachment, update the reference on the note and get the localpath. */
archive(remote: string, notepath: string, frontmatter?: unknown): Promise<string | undefined>
}
Plugins use Markdown post processing to change the rendered view of the note.
By default any image rendered by a plugin may be cached, dependening on the Cache priority.
But if the plugin uses async functions the order defined by Cache priority is not enforced, in that situations this plugin runs before the thrid-party plugin has ended and the added images avoid been cached.
To prevent that situation on 'NORMAL' priority 2 second is awaited before the cache is executed.
On 'HIGHER' priority 10 seconds are awaited.