Video component
Shipped in OINK v1.7.0, documented in the Video guide, and governed by the Components contract. Shared decisions are in the overview.
| Record | Value |
|---|---|
| Status | Accepted and shipped in OINK v1.7.0 (implemented 2026-11-27) |
| Owner | OINK maintainers |
| Delivery stages | S2 (files, autoplay), S4 (platform cards and players) |
| Form | Native: a block Markdown image whose destination is a video file or a recognized video-platform URL |
| New public API | Image attributes poster, track, autoplay for video; configuration params.video_embeds |
| Runtime | Shared js/chunks/media.js for file players and enabled platform cards |
| Affected surface | render-image.html, the shared resource lookup, a media partial, a stylesheet layer, the configuration schema, a new guide at /docs/components/video/ |
Summary
Video uses the syntax authors already use for images:
The image hook recognizes a video destination and hands it to a shared media
partial. A file becomes a native <video> with controls. autoplay=true turns
it into a muted, looping demo that plays only while visible and never under
reduced motion. A YouTube, Bilibili, or Vimeo URL becomes a static card that
links to the platform; when the site lists that platform in
params.video_embeds, clicking the card loads the platform’s player in place.
Problem
warns and drops today, because the image resolver accepts only image resources.- Authors fall back to raw
<video>with no caption, numbering, Print, or RSS form, and to raw<iframe>players that load third-party scripts and cookies on page view, shift the layout, fail where the platform is blocked, and rot when videos disappear. - Animated GIF demos are large and cannot be paused; the usual replacement is a
hand-written
autoplay loop mutedvideo that ignores reduced motion.
Evidence from local Markdown under ~/www and ~/pgsty (2026-11-27): two
blogs embed the same Bilibili <iframe> directly; a travel post uses raw
<video controls>; repository READMEs in the same corpus use autoplay loop muted videos whose URLs carry expiring signatures. No checkout uses Hugo’s
built-in youtube or vimeo shortcode.
Design principles
- A video is a figure. It has a source, an accessible name, an optional caption, and an optional Book number, exactly like an image. The image hook already owns all four, so video extends it instead of adding a shortcode.
- Precedent exists. GitLab Flavored Markdown renders image syntax that points at a video or audio file as a player, and Obsidian embeds YouTube videos written with image syntax. OINK’s own Draw.io component is a native image form.
- The URL is the identity. A platform URL is what readers, feeds, and agents understand, and it carries the start time. The theme derives player URLs from it at build time; nothing is fetched.
- No third-party request without consent. By default nothing leaves the page. With a site opt-in, the platform is contacted only after a reader clicks.
- Progressive enhancement. Every form works without JavaScript; the runtime replaces native file controls with the theme control row, coordinates audible players, gates autoplay on visibility, and opens enabled embeds in place.
Goals and non-goals
Goals
- Local, page-bundle, global-asset,
static/, and object-storage (HTTPS) video files. - Poster, one subtitle track, caption, Book numbering, and layout without shift when a size is known.
- A GIF replacement that is small, pausable, and respects reduced motion.
- YouTube, Bilibili, and Vimeo without third-party requests by default.
- Static, readable Print, RSS, Markdown, and LLMS forms.
Non-goals
- A
videoshortcode, or overriding Hugo’s built-inyoutubeandvimeo. - Codec fallbacks with several
<source>elements; MP4 (H.264) plays everywhere OINK supports. - Streaming (HLS/DASH), custom player chrome, playlists, chapters.
- Remote platform thumbnails, oEmbed, or any build-time request.
- Platforms beyond the three, or arbitrary iframe URLs.
Proposed behavior
Detection
A block image is a video when its destination is one of:
| Destination | Recognized by |
|---|---|
| Page, branch-bundle, or global resource | Hugo media type video/* |
static/ path or HTTPS URL |
Extension mp4, m4v, webm, ogv, or mov |
| Platform URL | A strict pattern below |
An inline image with a video destination renders as a plain link to the file or watch page, with the bracket text as link text. Anything else keeps today’s image behavior.
Attributes
| Attribute | Applies to | Rule |
|---|---|---|
caption, num, id |
All video | The shared figure contract; num registers a Book fig target |
poster |
All video | Image path through the shared image resolver. A local raster also supplies width/height |
track |
Files | One WebVTT file through the shared lookup. srclang is the page language; the label is the language name |
autoplay |
Files | true or false; see below. Warns and is ignored for platform URLs |
width, height |
All video | Positive integers; intrinsic size or aspect hint, overriding the poster’s |
link, command, and options warn and are dropped. The bracket text is the
accessible name. Without width/height or a local poster, the box reserves
16:9 until metadata loads.
Files
Unlike a block image, a video always renders inside a <figure>, with or
without caption or num.
autoplay=true emits muted loop playsinline and a data-td-media-autoplay
marker, but not the autoplay attribute. The runtime starts playback when at
least half of the video is visible, the page is visible, and the reader has not
asked for reduced motion; it pauses when the video leaves the viewport. The
control row stays, so the motion can always be paused. Without JavaScript the
reader sees the poster or first frame and plays it by hand.
Platform URLs
| Platform | Accepted URLs | Derived player |
|---|---|---|
| YouTube | youtube.com/watch?v=<id>, youtu.be/<id>, youtube.com/shorts/<id> with an 11-character ID; t or start |
https://www.youtube-nocookie.com/embed/<id>?start=…&autoplay=1 |
| Bilibili | bilibili.com/video/BV<id> or /video/av<number>; p and t |
https://player.bilibili.com/player.html?bvid=…&p=…&t=…&autoplay=1&danmaku=0 |
| Vimeo | vimeo.com/<number>, optionally /<hash> for unlisted videos |
https://player.vimeo.com/video/<number>?h=…&dnt=1&autoplay=1 |
IDs are validated against these patterns before any URL is built; author text
never enters a player URL. A b23.tv/BV… short link resolves to the player;
only an opaque short link that cannot be resolved offline, such as
b23.tv/abc, renders the card without a player and warns with the full-URL
form.
Default output is a card: the poster or a neutral surface, a play glyph, the bracket text, and the platform name, all inside one link to the canonical watch URL. No iframe, script, or thumbnail request.
With the platform listed in params.video_embeds, the card also carries the
derived player URL. On click, the runtime replaces the card with an iframe that
has the bracket text as title,
allow="autoplay; picture-in-picture; fullscreen",
sandbox="allow-scripts allow-same-origin allow-presentation allow-popups allow-popups-to-escape-sandbox",
allowfullscreen, and referrerpolicy="strict-origin-when-cross-origin", and
moves focus into it. Without JavaScript the link still opens the platform.
Configuration
A non-list warns and keeps cards only; unknown names warn and are ignored. A
list (rather than a boolean) lets a site enable Bilibili without YouTube when
part of its audience cannot reach YouTube. Sites with a Content Security Policy
add the enabled player hosts to frame-src; the guide lists them.
Outputs
| Output | Result |
|---|---|
| HTML | File players and enabled platform cards load the shared media.js |
Poster when present, caption and Book label, and the file or watch URL as visible text; no <video> or <iframe> |
|
| Markdown / LLMS | The authored source |
| RSS | Poster (absolute URL) when present and a link with the bracket text; no <video> or <iframe> |
Ordinary browser printing of HTML shows the poster or current frame; print rules reveal the URL beneath it.
Large files
A video in a page bundle is committed to Git. The guide recommends an
object-storage or CDN URL for anything beyond a few megabytes, in line with the
repository rules for binary assets. The theme does not measure file sizes at
build time; a size report belongs to oink-cli checks.
Trade-offs and alternatives
| Option | Decision | Reason |
|---|---|---|
First-draft {{< video >}} with src, youtube, bilibili, vimeo, webm, mp4, controls, muted, loop, gif, ratio, and more |
Rejected | About twenty parameters restate what image syntax and figure attributes already express, and a shortcode would be a second way to place video |
Overriding Hugo’s youtube and vimeo |
Rejected | Hugo’s vimeo can fetch from Vimeo at build time (its simple mode); each override widens divergence from Hugo (see the X parse finding); a URL is clearer than an ID |
gif=true that removes controls |
Renamed and changed | autoplay describes the behavior. Removing controls fails WCAG 2.2.2 (pause, stop, hide) |
The autoplay HTML attribute |
Rejected | It ignores reduced motion and keeps playing off-screen; the runtime gate is the accessible form |
| Remote platform thumbnails | Rejected | A third-party request on every view |
A boolean params.video_embeds |
Rejected | Reachability differs by platform and region |
Costs of the chosen form:
- Image syntax for video is a convention, not CommonMark semantics. Renderers other than GitLab show a broken image; the Markdown output keeps the URL, so agents still understand it.
- Discoverability shifts from a shortcode’s parameter list to the image guide; the cheatsheet gets its own Video row.
render-image.htmlgains a dispatch. The media branch lives in its own partial so the image path stays readable and its goldens unchanged.
Compatibility
Additive. A video destination produces a warning and no output today, so no
page depends on that behavior. Image output must stay byte-identical, which the
existing goldens verify. params.video_embeds is a new key.
Implementation plan
- Extract the lookup from
content/image-resolve.htmlinto a shared partial; image goldens must not change. - Add
content/media.html(detection, attributes, outputs) and dispatch to it fromrender-image.htmlbefore image-only work. - Add
assets/js/media.jsas the stable chunkjs/chunks/media.js, selected from a Page Store flag inscripts.html; unit tests undertests/js/with mockedIntersectionObserverandmatchMedia. - S4: platform patterns,
params.video_embedsinhugo.yaml,bin/check-params.py, and the generated configuration schema. - Locale keys in all 32 files:
ui_video_play(“Play video”) andui_video_open(“Open on the video site”), checked bybin/check-i18n.py. - Fixtures: files from each source kind, poster with and without size,
subtitles, autoplay, inline video, each platform pattern, invalid IDs, short
links, and each output. Owning checks:
check-media-primitives.py(the image hook and shared resolution),check-runtime-isolation.py(the chunk flag),check-output.py,check-output-security.py,check-goldens.py,check-stylesheets.py,check-params.py,check-i18n.py,node --test. - Browser review on this site: keyboard, focus after the player loads, reduced motion, presets, mobile, and print.
Acceptance criteria
- Pages with only plain platform links omit the media runtime.
- With
video_embeds: [], the HTML contains no player host URL. - Autoplay never starts under
prefers-reduced-motion: reduceand pauses off-screen. - Print, RSS, Markdown, and LLMS contain no
<video>,<iframe>, or runtime marker. - Existing image goldens are byte-identical.
Open decisions
- Uncaptioned video (resolved). The shipped implementation always wraps
videos in
<figure class="td-media">for a uniform frame and consistent print and typeset-copy output. - Subtitles. Recommended: one
trackper page; each language page names its own file. A list form is deferred. - Bilibili comments. Recommended:
danmaku=0with no option in S4. - Unknown size. Recommended: reserve 16:9; vertical videos set
width/heightor a poster.
Decision log
- 2026-11-27 (first draft).
videoshortcode with source modes, about twenty parameters,gif=true, and opt-in facades. - 2026-11-27 (review). Moved to native image syntax with three media
attributes, an accessible autoplay gate, platform URLs as identity, and a
per-platform
params.video_embedslist. - 2026-11-27 (implementation). Implemented in
content/media-detect.html,content/media.html,content/video-embeds.html,assets/js/media.jsandassets/css/td/media.css, with the lookup extracted intocontent/resource-lookup.html. Differences from this draft: the configuration key is the flat listparams.video_embeds(the parameter contract flattens single-key maps); a video without caption or number keeps atd-mediawrapper without a figcaption; Print and RSS name the video beside its URL; the locale keys areui_video_playandui_video_open. Both network settings are validated on every page. Eight invalid-input cases were added tobin/check-media-primitives.py, andtests/js/media.test.jscovers the runtime. - 2026-11-27 (review hardening). Fixed decimal parsing for leading-zero timestamps (
08s,010), expanded platform URL parsing (youtube-nocookie.com,music.youtube.com,player.vimeo.com, Vimeo?h=and#t=, uppercaseAV,b23.tv/BV…, trailing slashes, and9:16default ratio for YouTube Shorts), decoupled poster image dimensions from pairedwidth/heightaspect ratios, replacedsetTimeout(0)autoplay event tracking with a FIFO expected-event queue, added iframesandboxand tightenedallowand the runtime player-URL regex, excluded.td-media-card__posterfrom Draw.io detection, fixed dark-mode play-button contrast, poster scrim contrast, narrow-screen card grid overlap, portrait80vhsymmetry, forced-colors styling, RTL play-icon alignment, and Print/RSS watch URLs (including browser print after iframe replacement). Added zero-binary media-type and video matrix checks inbin/check-media-primitives.py,video_embedsitem enum generation inbin/generate-config-schema.py, andtests/browser/video.spec.mjs. - 2026-11-27 (acceptance review fixes). Cards carry their ratio as
--td-media-ratioand cap their width atmin(100%, 80vh × ratio)(card and player), because WebKit does not narrow a box whoseaspect-ratioheightmax-block-sizeclamps; where container units exist the ratio is a minimum height measured from the figure, because WebKit also keeps anaspect-ratiobox at its ratio height and clipped wrapped titles. Browser print gives poster-less card text the paper ink in dark mode. Draw.io skips only images insidea.td-media-cardagain, leaving other linked diagrams editable. Bilibili’s embed-codesrc,player.bilibili.com/player.html?bvid=…|aid=…, is recognized instead of rendering as a remote image. Covered by the video matrix and a stylesheet contract inbin/check-media-primitives.py,tests/js/drawio.test.jsandtests/browser/video.spec.mjs. - 2026-11-28 (control row). File videos share audio’s theme control row: one seek bar whose colors tell played, buffered and unloaded time apart, speed, a captions toggle for the one track, mute and volume, and full screen on the figure with the row kept under the picture (iPhone falls back to the native player). Clicking the picture toggles playback. Native
controlsremain the no-JavaScript fallback.