72 lines
3.0 KiB
HTML
72 lines
3.0 KiB
HTML
{{ $disableImageOptimization := .Site.Params.disableImageOptimization | default false }}
|
|
{{ if .Get "default" }}
|
|
{{ template "_internal/shortcodes/figure.html" . }}
|
|
{{ else }}
|
|
{{- $url := urls.Parse (.Get "src") }}
|
|
{{- $altText := .Get "alt" }}
|
|
{{- $caption := .Get "caption" }}
|
|
{{- $href := .Get "href" }}
|
|
{{- $class := .Get "class" }}
|
|
{{- $target := .Get "target" | default "_blank" }}
|
|
{{- $gallery_class := .Get "gallery_class" }}
|
|
|
|
<div class="panzoom-container {{ with $gallery_class }} {{ . }}{{ end }}">
|
|
{{- with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end -}}
|
|
{{- if findRE "^https?" $url.Scheme }}
|
|
<img class="my-0 rounded-md zoomable{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" />
|
|
{{- else }}
|
|
{{- $resource := "" }}
|
|
{{- if $.Page.Resources.GetMatch ($url.String) }}
|
|
{{- $resource = $.Page.Resources.GetMatch ($url.String) }}
|
|
{{- else if resources.GetMatch ($url.String) }}
|
|
{{- $resource = resources.Get ($url.String) }}
|
|
{{- end }}
|
|
{{- with $resource }}
|
|
{{ $rotationString := ""}}
|
|
{{- if ne .MediaType.SubType "svg" }}
|
|
{{- with .Exif}}
|
|
{{ $EXIFOrientation := .Tags.Orientation }}
|
|
{{ if eq $EXIFOrientation 3 }}
|
|
{{ $rotationString = "r180" }}
|
|
{{ else if eq $EXIFOrientation 4}}
|
|
{{ $rotationString = "r180" }}
|
|
{{ else if eq $EXIFOrientation 5}}
|
|
{{ $rotationString = "r270" }}
|
|
{{ else if eq $EXIFOrientation 6}}
|
|
{{ $rotationString = "r270" }}
|
|
{{ else if eq $EXIFOrientation 7}}
|
|
{{ $rotationString = "r90" }}
|
|
{{ else if eq $EXIFOrientation 8}}
|
|
{{ $rotationString = "r90" }}
|
|
{{- end}}
|
|
{{- end}}
|
|
{{- end}}
|
|
{{- if or $disableImageOptimization (eq .MediaType.SubType "svg")}}
|
|
<img
|
|
class="my-0 rounded-md zoomable{{ with $class }} {{ . }}{{ end }}"
|
|
src="{{ .RelPermalink }}"
|
|
alt="{{ $altText }}"
|
|
data-src="{{ $url.String }}"
|
|
/>
|
|
{{- else }}
|
|
<img
|
|
class="my-0 rounded-md zoomable{{ with $class }} {{ . }}{{ end }}"
|
|
src="{{ .RelPermalink }}"
|
|
srcset="
|
|
{{ (.Resize (printf "330x %s" $rotationString)).RelPermalink }} 330w,
|
|
{{ (.Resize (printf "660x %s" $rotationString)).RelPermalink }} 660w,
|
|
{{ (.Resize (printf "1320x %s" $rotationString)).RelPermalink }} 1320w,
|
|
{{ .RelPermalink }} 2x"
|
|
alt="{{ $altText }}"
|
|
data-src="{{ $url.String }}"
|
|
/>
|
|
{{- end }}
|
|
{{- else }}
|
|
<img class="my-0 rounded-md zoomable{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" data-src="{{ $url.String }}"/>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{ if $href }}</a>{{ end }}
|
|
</div>
|
|
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
|
{{- end -}}
|