Skip to content

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

License

Notifications You must be signed in to change notification settings

oylbin/obsidian-external-file-embed-and-link

Repository files navigation

External File Embed and Link

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 paths relative to Home directory or Vault directory for cross-device and cross-platform compatibility.
  4. Provide commands to add embeds or links via file picker.
  5. Support drag & drop to create embeds or links.

Detailed Usage

Embedding External Files

You can embed files using paths relative to your Home 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:

```EmbedRelativeToHome
SynologyDrive/work/Document.pdf
```

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

PDF Example

If your Obsidian vault is located at C:\Users\username\SynologyDrive\obsidian, you can embed the same file using a path relative to your vault:

```EmbedRelativeToVault
../work/Document.pdf
```

Using relative paths 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:

```EmbedRelativeToHome
SynologyDrive/work/Document.md#This is a header
```

PDF Files

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

```EmbedRelativeToHome
SynologyDrive/work/Document.pdf#page=3&width=100%&height=80vh
```

Images & Videos

Add dimensions after | to control size:

```EmbedRelativeToHome
Downloads/test.png|400
```
```EmbedRelativeToHome
Videos/test.mp4|800x600
```

External File Links

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

This is a pdf file outside of the vault:
```LinkRelativeToHome
Downloads/sample.pdf
```

This will be rendered as:

External Link Example

For inline links within paragraphs, use:

This is a <a class=LinkRelativeToHome>Downloads/sample.pdf</a> outside of the vault.

Which renders as:

Inline Link Example

Adding Embeds or Links

Using Commands

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

commands

Using Drag & Drop

Create embeds or links by holding modifier keys (ctrl, shift, ctrl+shift) while dragging files.

Modifier keys can be customized in the plugin settings:

settings

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published