mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-05 20:14:41 +00:00
12 lines
559 B
HTML
12 lines
559 B
HTML
{{ $directory := "img/" }}
|
|
{{ $video := printf "%s%s" $directory (.Get "src") }}
|
|
{{ $video_type := substr (.Get "src") -1 3 }}
|
|
{{ $poster := printf "%s%s%s" $directory (substr (.Get "src") 0 -4) ".jpg" }}
|
|
{{ if fileExists (printf "%s%s" "static/" $poster) }}
|
|
{{ .Scratch.Set "poster" ($poster | relURL) }}
|
|
{{ else }}
|
|
{{ .Scratch.Set "poster" "" }}
|
|
{{ end }}
|
|
<video {{if (.Get "controls")}}controls{{else}}autoplay loop{{end}} {{with .Scratch.Get "poster"}}poster="{{.}}"{{end}}>
|
|
<source src="{{ $video | relURL }}" type="video/{{$video_type}}">
|
|
</video> |