Skip to content

Commit fb4c653

Browse files
committed
fix: media layout
1 parent 388b1ab commit fb4c653

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

claude/layouts/_partials/shortcodes/media.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
{{- /* Plyr partial: renders HTML5 audio, HTML5 video, Vimeo, or YouTube */ -}}
22
<div class="hx:mx-auto hx:my-6">
33
{{- if eq .type "audio" -}}
4-
<audio controls
4+
<audio
55
{{- if eq (printf "%v" .autoplay) "true" }} autoplay{{ end -}}
6+
{{- if eq (printf "%v" .controls) "true" }} controls{{ end -}}
7+
{{- with .crossorigin }} crossorigin="{{ . }}"{{ end -}}
8+
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}
69
{{- if eq (printf "%v" .muted) "true" }} muted{{ end -}}
7-
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}>
10+
{{- " " }}preload="{{ .preload }}">
811
<source src="{{ .src }}" />
912
</audio>
1013
{{- else if eq .provider "vimeo" -}}
1114
<div data-plyr-provider="vimeo" data-plyr-embed-id="{{ .src }}"></div>
1215
{{- else if eq .provider "youtube" -}}
1316
<div data-plyr-provider="youtube" data-plyr-embed-id="{{ .src }}"></div>
1417
{{- else -}}
15-
<video playsinline controls
16-
{{- with .poster }} data-poster="{{ . }}"{{ end -}}
18+
<video
1719
{{- if eq (printf "%v" .autoplay) "true" }} autoplay{{ end -}}
20+
{{- if eq (printf "%v" .controls) "true" }} controls{{ end -}}
21+
{{- with .crossorigin }} crossorigin="{{ . }}"{{ end -}}
22+
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}
1823
{{- if eq (printf "%v" .muted) "true" }} muted{{ end -}}
19-
{{- if eq (printf "%v" .loop) "true" }} loop{{ end -}}>
24+
{{- if eq (printf "%v" .playsinline) "true" }} playsinline{{ end -}}
25+
{{- " " }}preload="{{ .preload }}">
2026
<source src="{{ .src }}" type="video/mp4" />
2127
</video>
2228
{{- end -}}

claude/layouts/_shortcodes/media.html

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
@param {string} [provider] The media provider: "youtube", "vimeo", or omit for HTML5.
88
@param {string} [type=video] The media type: "video" or "audio".
99
@param {bool} [autoplay=false] Whether to autoplay.
10-
@param {bool} [muted=false] Whether to mute.
10+
@param {bool} [controls=true] Whether to show player controls.
11+
@param {string} [crossorigin] The CORS setting: "anonymous" or "use-credentials".
1112
@param {bool} [loop=false] Whether to loop.
12-
@param {string} [poster] The poster image URL (HTML5 video only).
13+
@param {bool} [muted=false] Whether to mute.
14+
@param {bool} [playsinline=true] Whether to play inline on mobile.
15+
@param {string} [preload=auto] The preload behavior: "none", "metadata", or "auto".
1316

1417
@example {{< media src="media/example.mp4" >}}
1518
@example {{< media src="bTqVqk7FSmY" provider="youtube" >}}
@@ -20,10 +23,12 @@
2023
{{- $provider := .Get "provider" | default "" -}}
2124
{{- $type := .Get "type" | default "video" -}}
2225
{{- $autoplay := .Get "autoplay" | default false -}}
23-
{{- $muted := .Get "muted" | default false -}}
26+
{{- $controls := .Get "controls" | default true -}}
27+
{{- $crossorigin := .Get "crossorigin" | default "" -}}
2428
{{- $loop := .Get "loop" | default false -}}
25-
{{- $poster := .Get "poster" | default "" -}}
26-
29+
{{- $muted := .Get "muted" | default false -}}
30+
{{- $playsinline := .Get "playsinline" | default true -}}
31+
{{- $preload := .Get "preload" | default "auto" -}}
2732
{{- if not $src -}}
2833
{{- errorf "Media 'src' must be supplied" -}}
2934
{{- end -}}
@@ -47,8 +52,11 @@
4752
"src" $src
4853
"provider" $provider
4954
"type" $type
50-
"autoplay" $autoplay
51-
"muted" $muted
52-
"loop" $loop
53-
"poster" $poster
55+
"autoplay" $autoplay
56+
"controls" $controls
57+
"crossorigin" $crossorigin
58+
"loop" $loop
59+
"muted" $muted
60+
"playsinline" $playsinline
61+
"preload" $preload
5462
) -}}

0 commit comments

Comments
 (0)