feat: add option to disable zoom in re-written Figure shortcode

Compatible with previous `lightbox` option.
This commit is contained in:
George Cushen 2021-02-19 13:13:00 +00:00
commit eebefd8a59

View file

@ -3,6 +3,7 @@
{{ $destination := .Get "src" }} {{ $destination := .Get "src" }}
{{ $caption := .Get "caption" | default (.Get "title") | default "" }}{{/* Support legacy `title` option. */}} {{ $caption := .Get "caption" | default (.Get "title") | default "" }}{{/* Support legacy `title` option. */}}
{{ $zoom := eq (.Get "lightbox" | default "true") "true" }}
{{ $id := anchorize (.Get "id" | default ($caption | plainify)) }} {{ $id := anchorize (.Get "id" | default ($caption | plainify)) }}
{{ $alt := .Get "alt" | default ($caption | plainify) }} {{ $alt := .Get "alt" | default ($caption | plainify) }}
@ -19,7 +20,7 @@
<img alt="{{ $alt }}" <img alt="{{ $alt }}"
src="{{ $img.RelPermalink }}" src="{{ $img.RelPermalink }}"
loading="lazy" loading="lazy"
data-zoomable {{ if $zoom }}data-zoomable{{end}}
{{ with .Get "width" }}width="{{.}}"{{end}} {{ with .Get "height" }}height="{{.}}"{{end}} /> {{ with .Get "width" }}width="{{.}}"{{end}} {{ with .Get "height" }}height="{{.}}"{{end}} />
{{ else }} {{ else }}
{{- $img_lg := $img.Fit "1200x1200" -}} {{- $img_lg := $img.Fit "1200x1200" -}}
@ -35,10 +36,10 @@
width="{{ $width }}" width="{{ $width }}"
height="{{ $height }}" height="{{ $height }}"
loading="lazy" loading="lazy"
data-zoomable /> {{ if $zoom }}data-zoomable{{end}} />
{{ end }} {{ end }}
{{- else -}} {{- else -}}
<img src="{{ $destination | safeURL }}" alt="{{ $alt }}" loading="lazy" data-zoomable <img src="{{ $destination | safeURL }}" alt="{{ $alt }}" loading="lazy" {{ if $zoom }}data-zoomable{{end}}
{{ with .Get "width" }}width="{{.}}"{{end}} {{ with .Get "height" }}height="{{.}}"{{end}} /> {{ with .Get "width" }}width="{{.}}"{{end}} {{ with .Get "height" }}height="{{.}}"{{end}} />
{{- end -}} {{- end -}}