Attachments Cache

by luisbs
5
4
3
2
1
Score: 44/100

Description

The Attachments Cache plugin enables Obsidian users to automatically cache remote image files locally within their vaults without altering the original note content. When an image is rendered in a note, the plugin checks for an existing cached version or downloads it to a specified folder if not already present. This local cache ensures images remain visible even offline while preserving the original remote URL references for portability.

Reviews

No reviews yet.

Stats

9
stars
676
downloads
1
forks
418
days
181
days
181
days
16
total PRs
0
open PRs
1
closed PRs
15
merged PRs
2
total issues
1
open issues
1
closed issues
0
commits

Latest Version

6 months ago

Changelog

0.7.0

Minor Changes

  • 4075c63: Added support for all Obsidian supported file-formats.
  • ce88026: Added caching command for current editor
  • 260811d: Added logic for archiving attachments and updating the notes.
  • e65128b: Added caching process on paste event
  • c9a590a: Added caching command for selected text

Patch Changes

  • 51bf6b6: Added setting to toggle caching onRender
  • 7f4b529: Added setting to toggle caching onPaste

README file from

Github

Attachments Cache

License: GPL v3

If you search help about the Settings you can check the documentation.

Summary

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:

  1. The plugin checks if the image is cached/should be cached.
  2. Download the image into a vault folder if is not cached.
  3. Modify the img element to use the cached file inside the vault.

Features

  • Exposed API for thrid-party integration.
  • Whitelist/blacklist vault vault paths to perform caching.
  • Whitelist/blacklist vault remote URLs to perform caching.
  • For listed Vault paths define where to store the attachments.
  • Allows override of rules on individual notes or remotes.

Supported attachments file-formats

Based on the Obsidian supported file-formats the next attachments formats are been cached:

  • Images: .avif, .bmp, .gif, .jpeg, .jpg, .png, .svg, .webp
  • Audio: .flac, .m4a, .mp3, .ogg, .wav, .webm, .3gp
  • Video: .mkv, .mov, .mp4, .ogv, .webm
  • PDF: .pdf

Instalation

From within Obsidian

You can activate this plugin within Obsidian by doing the following:

  • Open Settings > Third-party plugin
  • Make sure Safe mode is off
  • Click Browse community plugins
  • Search for "Attachments Cache"
  • Click Install
  • Once installed, enable the plugin
  • Then select "Attachments Cache" settings
  • Configure the vault paths and URL remotes that should be cached

From source

You can activate this plugin, building from source by doing the following:

  • Clone the repository
  • Install the dependencies
  • Run pnpm build:dist or an equivalent.
  • Copy the content of the repository dist folder to your vault, the path should look like <path-to-your-vault>/.obsidian/plugins/attachments-cache
  • Open your vault in Obsidian and activate the newly installed plugin

Pricing

This 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:

Notes

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.

Thrid-party Integration

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>
}

Troubleshooting

An image rendered by another plugin is not been cached?

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.

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Custom Attachment Location
5 years ago by RainCat1998
Customize attachment location with variables($filename, $data, etc) like typora.
Paste image rename
4 years ago by Reorx
Renames pasted images and all the other attachments added to the vault
Consistent attachments and links
5 years ago by Dmitry Savosh
Obsidian plugin. Move note with attachments.
File Cleaner Redux
2 years ago by husjon
A plugin for Obsidian to help clean up files in your vault
Attachment Management
3 years ago by trganda
Attachment Management of Obsidian
Janitor
4 years ago by Gabriele Cannata
Performs various maintenance tasks on the Obsidian vault
Obsidian markdown export
3 years ago by bingryan
This plugin allows to export directory/single markdown to a folder. support output format(html/markdown/text)
File Cleaner
4 years ago by Johnson0907
A file cleaner plugin for Obsidian.
Unique attachments
5 years ago by Dmitry Savosh
Obsidian plugin. Renames attachments, making their names unique.
Nuke Orphans
4 years ago by Sandorex
Obsidian notes plugin that trashes orphaned files and attachments
Google Keep Import
3 years ago by Dale de Silva
Imports Google Keep backup files
Linked Note Exporter
9 months ago by the-c0d3r
Obsidian plugin to export a note along with all its attachments and linked notes—cleanly, conveniently, and ready to share.
Insert Multiple Attachments
a year ago by mnaoumov
Obsidian Plugin that allows to insert multiple attachments at a time
S3 attachments storage
3 years ago by TechTheAwesome
An Obsidian plugin for storage and retrieval of media attachments on S3 compatible services.
Import Attachments+
2 years ago by Andrea Alberti
Import attachments by moving them into the vault.
Attachment Uploader
2 years ago by zhuxining
An attachment uploader plugin for Obsidian
Image Size
a year ago by Jie Zhang
Set the default size for pasted images.
Local Any Files
a year ago by ShermanTsang
A obsidian plugin used to extract and download files in your obsidian note.
Note Companion Folder
2 years ago by Chris Verbree
A Obsidian Plugin providing a way to associate a folder to a note
Cloud Storage
2 years ago by Jiajun Ma
Obsidian Cloud Storage is a powerful and user-friendly plugin designed to seamlessly integrate cloud storage capabilities into your Obsidian workflow. This plugin allows you to effortlessly upload your attachments to the cloud, freeing up local storage space and enabling easy sharing and access across all your devices.
Paste Image Into Property
a year ago by Nito
Auto Folder Note Paste
a year ago by d7sd6u
Convert your note into folder note upon pasting or drag'n'dropping an attachment
Come Down
a year ago by mntno
An Obsidian plugin that maintains a cache of your notes’ embedded external images.
Infostacker Note Publish
2 years ago by Taskscape LTD, Patryk Nowak, Kacper Pabianiak
Infostacker plugin for Obisidian
Lskypro Upload V2
2 months ago by 3kk0
Auto upload local images to LskyPro.