Color mode

Media

Renders Obsidian audio / video attachment embeds with native HTML5 media players.

日本語

Overview

media() provides an attachment renderer for common Web media formats such as ![[music.mp3]] and ![[movie.mp4]]. Unsupported files return null, allowing later renderers or the default fallback to handle them.

Usage

ts
import { defineConfig } from "@riebeckite/core";
import { attachment } from "@riebeckite/plugin-attachment";
import { media } from "@riebeckite/plugin-media";
import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
 
export default defineConfig({
  // ...
  plugins: [obsidianMarkdown(), media(), attachment()],
});

media() uses order: -10, so it runs before the default attachment card.

Supported formats

  • audio: mp3, m4a, aac, ogg, oga, opus, wav, flac
  • video: mp4, m4v, webm, ogv, mov

Options

Option Type Default Description
preload "none" | "metadata" | "auto" "none" when lazy: true, otherwise "metadata" preload for <audio> / <video>
lazy boolean true Uses "none" when preload is omitted to reduce eager loading
showCaption boolean true Shows a caption
showDownload boolean true Shows a download link
showOpenOriginal boolean true Shows an original file link

Timestamp fragments

When a renderer receives fragments such as #t=10 or #10,20, they are kept on the media source URL. The current Obsidian wikilink pipeline does not pass attachment fragments to renderers, so full ![[movie.mp4#t=10]] support requires a future pipeline extension.

Exports

  • media(options?) / mediaPlugin — plugin factory
  • Types: MediaOptions, MediaPreload

See also

History

1 changesCollapseExpand
1 + <!-- Generated from packages/plugins/media/README.md. Do not edit this page directly; edit the package README and run `pnpm docs:sync`. -->
2 +
3 + # Media
4 +
5 + Renders Obsidian audio / video attachment embeds with native HTML5 media players.
6 +
7 + [日本語](./media.md)
8 +
9 + ## Overview
10 +
11 + `media()` provides an attachment renderer for common Web media formats such as
12 + `![[music.mp3]]` and `![[movie.mp4]]`. Unsupported files return `null`, allowing
13 + later renderers or the default fallback to handle them.
14 +
15 + ## Usage
16 +
17 + ```ts
18 + import { defineConfig } from "@riebeckite/core";
19 + import { attachment } from "@riebeckite/plugin-attachment";
20 + import { media } from "@riebeckite/plugin-media";
21 + import { obsidianMarkdown } from "@riebeckite/plugin-obsidian-markdown";
22 +
23 + export default defineConfig({
24 + // ...
25 + plugins: [obsidianMarkdown(), media(), attachment()],
26 + });
27 + ```
28 +
29 + `media()` uses `order: -10`, so it runs before the default attachment card.
30 +
31 + ## Supported formats
32 +
33 + - audio: `mp3`, `m4a`, `aac`, `ogg`, `oga`, `opus`, `wav`, `flac`
34 + - video: `mp4`, `m4v`, `webm`, `ogv`, `mov`
35 +
36 + ## Options
37 +
38 + | Option | Type | Default | Description |
39 + | ------ | ---- | ------- | ----------- |
40 + | `preload` | `"none" \| "metadata" \| "auto"` | `"none"` when `lazy: true`, otherwise `"metadata"` | `preload` for `<audio>` / `<video>` |
41 + | `lazy` | `boolean` | `true` | Uses `"none"` when `preload` is omitted to reduce eager loading |
42 + | `showCaption` | `boolean` | `true` | Shows a caption |
43 + | `showDownload` | `boolean` | `true` | Shows a download link |
44 + | `showOpenOriginal` | `boolean` | `true` | Shows an original file link |
45 +
46 + ## Timestamp fragments
47 +
48 + When a renderer receives fragments such as `#t=10` or `#10,20`, they are kept on
49 + the media source URL. The current Obsidian wikilink pipeline does not pass
50 + attachment fragments to renderers, so full `![[movie.mp4#t=10]]` support requires
51 + a future pipeline extension.
52 +
53 + ## Exports
54 +
55 + - `media(options?)` / `mediaPlugin` — plugin factory
56 + - Types: `MediaOptions`, `MediaPreload`
57 +
58 + ## See also
59 +
60 + - [Plugin guide](../reference/plugin-api.en.md)
61 +