External File Embed and Link

by oylbin
5
4
3
2
1
Score: 50/100

Description

The External File Embed and Link plugin allows Obsidian users to embed and link files located outside their vault using relative paths. It supports a variety of file types, including PDFs, images, audio, and videos, ensuring compatibility across devices and platforms. Users can reference files relative to the Home or Vault directory, which is particularly useful for cross-platform workflows. The plugin includes features such as drag-and-drop support, customizable embedding options, and commands for creating file links or embeds via a file picker. Additional parameters enable users to control the display of embedded content, such as PDF page numbers or image dimensions, making it a versatile tool for integrating external resources into Obsidian notes.

Reviews

No reviews yet.

Stats

50
stars
5,759
downloads
2
forks
486
days
28
days
28
days
4
total PRs
0
open PRs
0
closed PRs
4
merged PRs
22
total issues
8
open issues
14
closed issues
20
commits

Latest Version

a month ago

Changelog

README file from

Github

Embed and link local files outside your obsidian vault with relative paths for cross-device and multi-platform compatibility.

Features

  1. Embed external files (Markdown, PDF, Images, Audio, Video) outside your obsidian vault.
  2. Create links to files outside your obsidian vault that open with system default applications.
  3. Reference files using virtual directories for cross-device and cross-platform compatibility.
  4. Provide commands to add embeds or links via file picker.

Virtual Directories

The plugin uses a flexible virtual directory system that allows you to:

  • Map any local directory to a virtual directory ID
  • Configure different paths per device for the same virtual directory ID
  • Access files using the format: VirtualDirectoryId://relative/path/to/file

Home and vault directories are pre-defined as virtual directories:

  • home:// - Points to your user home directory
  • vault:// - Points to your Obsidian vault directory

You can define additional virtual directories in the plugin settings. This allows you to:

  1. Use the same note across multiple devices, even when file paths differ
  2. Reference files outside your vault in a consistent way
  3. Maintain compatibility across different operating systems

Detailed Usage

Embedding External Files

You can embed files using paths relative to a virtual directory. For example, if your Home path is C:\Users\username, you can embed a PDF file from C:\Users\username\SynologyDrive\work\Document.pdf like this:

```EmbedRelativeTo
home://SynologyDrive/work/Document.pdf
```

This will be rendered in Live Preview and Reading Mode as:

PDF Example

You can also use a custom virtual directory. For example, if you've defined a virtual directory called "project" that points to different paths on different computers:

```EmbedRelativeTo
project://documents/report.pdf
```

Using virtual directories ensures compatibility across different computers and operating systems, especially useful when syncing files with services like SynologyDrive.

Supported File Types for Embedding

Almost the same as Obsidian's Accepted file formats documentation except for JSON Canvas files.

  • Markdown: .md, .markdown, .txt
  • 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

Embedding Options

Following Obsidian's Embed files documentation, this plugin supports parameters for controlling display behavior:

Markdown Files

Add header name after # to embed only the header section:

```EmbedRelativeTo
home://SynologyDrive/work/Document.md#This is a header
```
PDF Files

Add parameters after # to control page number, width, and height:

```EmbedRelativeTo
home://SynologyDrive/work/Document.pdf#page=3&width=100%&height=80vh
```
Images & Videos

Add dimensions after | to control size:

```EmbedRelativeTo
home://Downloads/test.png|400
```
```EmbedRelativeTo
home://Videos/test.mp4|800x600
```
Folders

You can embed a folder by put /# after the folder name , and it will list all the files in the folder. You can also add parameters after # to filter the files to embed.

```EmbedRelativeTo
home://Downloads/#extensions=pdf,mp4
```

If you don't need to render the file content in Reading Mode, you can create inline links within paragraphs to external files:

This is a <a href="#home://Downloads/sample.pdf" class="LinkRelativeTo">sample.pdf</a> outside of the vault.

Which renders as:

Inline Link Example

Using Commands

Type "external" in the command palette to see available options:

  • Add external embed: Opens a dialog to select a virtual directory and file for embedding
  • Add external inline link: Opens a dialog to select a virtual directory and file for linking

Both commands will automatically generate the appropriate code with the correct syntax.

commands

Development

This project follows a containerized DevOps workflow. The host machine only needs Docker (with Docker Compose v2) and bash; Node.js is not required on the host.

The Makefile is the single entry point and forwards every command to dev.sh, which executes the actual logic inside a node:18-alpine container.

Prerequisites

  • Docker Desktop (or Docker Engine) with Docker Compose v2
  • bash (Git Bash or WSL on Windows)

Quick Start

# 1. Configure your local plugin directory
cp .env.example .env
# Edit .env and set VAULT_PLUGIN_DIR to your Obsidian plugin folder, e.g.
#   VAULT_PLUGIN_DIR=~/SynologyDrive/AppDataSync/obsidian/.obsidian/plugins/external-file-embed-and-link

# 2. Verify your environment
make doctor

# 3. Start the dev container (runs esbuild in watch mode in the background)
make up
make logs        # follow esbuild output

# 4. Build a production bundle
make build

# 5. Deploy to your Obsidian vault
make install     # host-side cp main.js / styles.css / manifest.json -> $VAULT_PLUGIN_DIR

# 6. Stop the dev container
make down

Available Targets

Run make help to see them all. Key targets:

Target Description
make help Show all available targets
make doctor Check Docker / Docker Compose / .env configuration
make deps Install npm dependencies inside the container
make lint Run ESLint inside the container
make build Build the plugin (production mode) inside the container
make clean Remove main.js
make test Run Jest unit tests inside the container
make up Start the dev container (esbuild watch in background)
make down Stop the dev container
make restart Restart the dev container
make status Show container status
make logs Tail dev container logs
make shell Open a shell inside the dev container
make artifacts List build artifacts (main.js, styles.css, manifest.json)
make install Host-side: copy artifacts to $VAULT_PLUGIN_DIR
make release Bump version and tag (make release VERSION=x.y.z)

Notes

  • node_modules is stored in a Docker named volume to avoid host/container binary mismatches (notably for esbuild's native binaries on Windows). It is not visible on the host filesystem; if you want IDE intellisense, you can run npm install on the host independently — this is optional and outside the containerized workflow.
  • make install is the only target that runs on the host. It simply executes cp and requires nothing beyond bash.
  • make release VERSION=x.y.z bumps the version (inside the container, via npm version --no-git-tag-version), commits the bump on the host, creates a git tag locally, and prints the push instructions. The existing GitHub Actions workflow on tag push handles the actual release.

Acknowledgement and License Notice

This project uses PDF.js for PDF rendering, which is made available under the Apache License 2.0. A copy of the PDF.js license can be found in the LICENSE file of the PDF.js repository.

If you distribute this project or its binaries, please ensure that you include the appropriate copyright and license notices as required by the Apache License 2.0.

For more information on PDF.js and its contributors, visit the official GitHub repository.

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.