Skip to content

Commit d5324dc

Browse files
committed
1 parent 98c6843 commit d5324dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
Support for embedding self-hosted videos.
3+
Put this file in /layouts/shortcodes/video.html
4+
5+
@copyright Copyright 2024 Hermès Bélusca-Maïto <[email protected]>
6+
@license GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
7+
8+
Based on snippets from:
9+
https://iamsorush.com/posts/add-video-to-hugo-post/
10+
https://roneo.org/en/hugo-create-a-shortcode-for-local-videos/
11+
https://github.com/martignoni/hugo-video
12+
-->
13+
{{- $width := "100%" -}}
14+
<video class="video-shortcode" width="{{ or (.Get "width") $width }}" {{ with .Get "height" }}height="{{.}}"{{ end }} preload="{{ .Get "preload" }}" {{ if ne (.Get "controls") "false" }}controls {{ end }} {{ if eq (.Get "autoplay") "true" }}autoplay {{ end }} {{ if eq (.Get "loop") "true" }}loop {{ end }}{{ if eq (.Get "muted") "true" }}muted {{ end }}playsinline>
15+
<source src="{{ .Get "src" }}" type="{{ .Get "type" }}">
16+
There should have been a video here but your browser does not seem to support it.
17+
</video>

0 commit comments

Comments
 (0)