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-01-14 00:24:41 +00:00
|
|
|
<figure{{ with $class }} class="{{ . }}"{{ end }}>
|
|
|
|
{{ with $href }}<a href="{{ . }}">{{ end }}
|
|
|
|
<img
|
|
|
|
class="mx-auto my-0 rounded-md"
|
|
|
|
alt="{{ $altText }}"
|
2023-05-26 21:26:57 +00:00
|
|
|
loading="lazy"
|
2023-01-14 00:24:41 +00:00
|
|
|
{{ if findRE "^https?" $url.Scheme }}
|
|
|
|
src="{{ $url.String }}"
|
|
|
|
{{ 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 }}
|
2023-01-14 23:38:53 +00:00
|
|
|
{{ if eq .MediaType.SubType "svg" }}
|
2023-01-14 00:24:41 +00:00
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ else }}
|
2023-01-14 23:38:53 +00:00
|
|
|
{{ if lt .Width 660 }}
|
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ else }}
|
|
|
|
srcset="
|
2023-03-23 17:52:41 +00:00
|
|
|
{{- (.Resize "330x").RelPermalink }} 330w,
|
|
|
|
{{- (.Resize "660x").RelPermalink }} 660w,
|
|
|
|
{{- (.Resize "1024x").RelPermalink }} 1024w,
|
|
|
|
{{- (.Resize "1320x").RelPermalink }} 2x"
|
2023-01-14 23:38:53 +00:00
|
|
|
src="{{ (.Resize "660x").RelPermalink }}"
|
|
|
|
{{ end }}
|
2023-01-14 00:24:41 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
|
|
|
src="{{ $url.String }}"
|
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
|
|
|
/>
|
|
|
|
{{ with $href }}</a>{{ end }}
|
|
|
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
|
|
|
</figure>
|
2022-08-18 04:59:46 +00:00
|
|
|
{{ end }}
|