2022-02-03 00:37:09 +00:00
|
|
|
{{ if .Get "default" }}
|
|
|
|
{{ template "_internal/shortcodes/figure.html" . }}
|
2022-01-12 03:21:22 +00:00
|
|
|
{{ else }}
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ $url := urls.Parse (.Get "src") }}
|
2022-02-03 00:37:09 +00:00
|
|
|
{{ $altText := .Get "alt" }}
|
|
|
|
{{ $caption := .Get "caption" }}
|
|
|
|
{{ $href := .Get "href" }}
|
|
|
|
{{ $class := .Get "class" }}
|
2023-10-31 16:53:15 +00:00
|
|
|
|
|
|
|
{{ $file := $url.Path }}
|
|
|
|
{{ $img := .Page.Resources.GetMatch $file }}
|
|
|
|
{{- if and (not $img) .Page.File }}
|
|
|
|
{{ $path := path.Join .Page.File.Dir $file }}
|
|
|
|
{{ $img = resources.Get $path }}
|
|
|
|
{{ end -}}
|
|
|
|
|
2023-01-14 00:24:41 +00:00
|
|
|
<figure{{ with $class }} class="{{ . }}"{{ end }}>
|
|
|
|
{{ with $href }}<a href="{{ . }}">{{ end }}
|
2023-10-31 16:53:15 +00:00
|
|
|
|
|
|
|
{{- with $img -}}
|
2023-11-29 13:51:44 +00:00
|
|
|
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
|
|
|
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
|
|
|
{{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" $lazy "webp" $webp) }}
|
2023-10-31 16:53:15 +00:00
|
|
|
{{- else -}}
|
|
|
|
<img src="{{ $url.String }}" alt="{{ $altText }}" class="{{ $class }}"/>
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-01-14 00:24:41 +00:00
|
|
|
{{ with $href }}</a>{{ end }}
|
|
|
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
|
|
|
</figure>
|
2022-08-18 04:59:46 +00:00
|
|
|
{{ end }}
|