Add support for embedding videos in the figures/image shortcode
This commit is contained in:
parent
d679ae6c39
commit
8bfa3fc8bf
1 changed files with 29 additions and 25 deletions
|
@ -17,31 +17,35 @@
|
||||||
{{ errorf "No images found for name(s) parameter" }}
|
{{ errorf "No images found for name(s) parameter" }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<figure class="figure figure--image{{ with $class }} {{ . }}{{ end }}">
|
{{ with $item := index $imgs 0 }}
|
||||||
<div class="figure__container">
|
<figure class="figure figure--{{ $item.ResourceType }}{{ with $class }} {{ . }}{{ end }}">
|
||||||
{{ range $img := $imgs }}
|
<div class="figure__container">
|
||||||
{{- $linkedImg := $img -}}
|
{{ if eq $item.ResourceType "image" }}
|
||||||
{{- if not $img }}
|
{{- $processedImage := $item -}}
|
||||||
{{ errorf "Found nil in images list for %s" $.Page.Permalink }}
|
{{- if $shouldResize -}}
|
||||||
{{ end -}}
|
{{ $processedImage = $item.Fit "1280x1280" }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- if $shouldResize -}}
|
{{- $altText := $item.Params.alt | default $item.Title -}}
|
||||||
{{ $linkedImg = $img.Fit "1280x1280" }}
|
<a href="{{ $item.RelPermalink }}">
|
||||||
|
<img src="{{ $processedImage.RelPermalink }}"
|
||||||
|
{{- with $altText }} alt="{{ . }}"{{- end }}
|
||||||
|
{{- with $item.Title }} title="{{ . }}"{{- end }}>
|
||||||
|
</a>
|
||||||
|
{{ else if eq $item.ResourceType "video" }}
|
||||||
|
<video controls width="100%">
|
||||||
|
<source src="{{ $item.RelPermalink }}" type="{{ $item.MediaType.Type }}">
|
||||||
|
</video>
|
||||||
|
{{- end }}
|
||||||
|
</div>
|
||||||
|
{{ if $shouldShowTitle -}}
|
||||||
|
{{- with $item -}}
|
||||||
|
{{- if gt (len .Title) 0 -}}
|
||||||
|
<figcaption>{{ .Title | markdownify }}</figcaption>
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- $altText := $img.Params.alt | default $img.Title -}}
|
|
||||||
<a href="{{ $img.RelPermalink }}">
|
|
||||||
<img src="{{ $linkedImg.RelPermalink }}"
|
|
||||||
{{- with $altText }} alt="{{ . }}"{{- end }}
|
|
||||||
{{- with $img.Title }} title="{{ . }}"{{- end }}>
|
|
||||||
</a>
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</div>
|
</figure>
|
||||||
{{ if $shouldShowTitle -}}
|
{{ else }}
|
||||||
{{- range $imgs -}}
|
{{ errorf "Found nil in items list for %s" $.Page.Permalink }}
|
||||||
{{- if gt (len .Title) 0 -}}
|
{{ end }}
|
||||||
<figcaption>{{ .Title }}</figcaption>
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end }}
|
|
||||||
</figure>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue