update render-image to support video embed

just like embed an image, use ![](/path/to/video.mov)
This commit is contained in:
Reorx 2022-06-02 11:44:11 +08:00
parent 88b2584d06
commit a2a26eb189
2 changed files with 11 additions and 3 deletions

View File

@ -5,7 +5,16 @@
{{- end -}}
{{- if $img -}}
<img loading="lazy" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} />
{{- if eq $img.MediaType.MainType "video" -}}
<figure>
<video class="video-shortcode" preload="metadata" controls>
<source src="{{ $img.RelPermalink }}">
There should have been a video here but your browser does not seem to support it.
</video>
</figure>
{{- else -}}
<img loading="lazy" src="{{ $img.RelPermalink }}" type="" alt="{{ $.Text }}" {{ with $.Title}} title="{{ . }}" {{ end }} />
{{- end -}}
{{- else -}}
{{- warnf "No image found for %s from %s" .Destination .Page.File }}
{{- end -}}

View File

@ -1,7 +1,6 @@
<figure>
<video class="video-shortcode" preload="{{ .Get "preload" }}" controls>
<source src="{{ .Get "src" }}" type="{{ .Get "type" }}">
There should have been a video here but your browser does not seem
to support it.
There should have been a video here but your browser does not seem to support it.
</video>
</figure>