2022-02-06 00:26:37 +00:00
|
|
|
{{ $url := urls.Parse .Destination }}
|
2022-01-12 03:21:22 +00:00
|
|
|
{{ $altText := .Text }}
|
|
|
|
{{ $caption := .Title }}
|
2023-05-26 21:37:02 +00:00
|
|
|
{{ $lazyLoad := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
2023-09-12 19:19:27 +00:00
|
|
|
{{ $webp := $.Page.Site.Params.enableWebp | default true }}
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ if findRE "^https?" $url.Scheme }}
|
2022-01-12 03:21:22 +00:00
|
|
|
<figure>
|
2023-05-26 21:31:23 +00:00
|
|
|
<img
|
|
|
|
class="mx-auto my-0 rounded-md"
|
|
|
|
src="{{ $url.String }}"
|
|
|
|
alt="{{ $altText }}"
|
2023-05-26 21:37:02 +00:00
|
|
|
{{ if $lazyLoad }}
|
2023-05-26 21:31:23 +00:00
|
|
|
loading="lazy"
|
|
|
|
{{ end }}
|
|
|
|
/>
|
2023-01-13 00:41:28 +00:00
|
|
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
2022-01-12 03:21:22 +00:00
|
|
|
</figure>
|
|
|
|
{{ else }}
|
2022-03-07 22:51:19 +00:00
|
|
|
{{ $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 }}
|
2022-02-06 00:26:37 +00:00
|
|
|
<figure>
|
2023-09-11 13:11:55 +00:00
|
|
|
<picture>
|
2023-09-12 19:19:27 +00:00
|
|
|
{{ if (and (ne .MediaType.SubType "svg") $webp) }}
|
2023-09-11 13:11:55 +00:00
|
|
|
<source
|
|
|
|
{{ if lt .Width 660 }}
|
|
|
|
{{ with .Resize (printf "%dx%d webp" .Width .Height) }}
|
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
|
|
|
srcset="
|
|
|
|
{{- (.Resize "330x webp").RelPermalink }} 330w,
|
|
|
|
{{- (.Resize "660x webp").RelPermalink }} 660w,
|
|
|
|
{{- (.Resize "1024x webp").RelPermalink }} 1024w,
|
|
|
|
{{- (.Resize "1320x webp").RelPermalink }} 2x"
|
|
|
|
src="{{ (.Resize "660x webp").RelPermalink }}"
|
|
|
|
{{ end }}
|
|
|
|
type="image/webp"
|
|
|
|
/>
|
|
|
|
{{ end }}
|
|
|
|
<img
|
|
|
|
class="mx-auto my-0 rounded-md"
|
|
|
|
{{ if eq .MediaType.SubType "svg" }}
|
2023-01-14 23:38:53 +00:00
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ else }}
|
2023-09-11 13:11:55 +00:00
|
|
|
width="{{ .Width }}"
|
|
|
|
height="{{ .Height }}"
|
|
|
|
decoding="async"
|
|
|
|
{{ if lt .Width 660 }}
|
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ else }}
|
|
|
|
srcset="
|
|
|
|
{{- (.Resize "330x").RelPermalink }} 330w,
|
|
|
|
{{- (.Resize "660x").RelPermalink }} 660w,
|
|
|
|
{{- (.Resize "1024x").RelPermalink }} 1024w,
|
|
|
|
{{- (.Resize "1320x").RelPermalink }} 2x"
|
|
|
|
src="{{ (.Resize "660x").RelPermalink }}"
|
|
|
|
{{ end }}
|
2023-01-14 23:38:53 +00:00
|
|
|
{{ end }}
|
2023-09-11 13:11:55 +00:00
|
|
|
alt="{{ $altText }}"
|
|
|
|
{{ if $lazyLoad }}
|
|
|
|
loading="lazy"
|
|
|
|
{{ end }}
|
|
|
|
/>
|
|
|
|
</picture>
|
2023-01-13 00:41:28 +00:00
|
|
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
2022-02-06 00:26:37 +00:00
|
|
|
</figure>
|
|
|
|
{{ else }}
|
2022-03-07 22:51:19 +00:00
|
|
|
<figure>
|
2023-05-26 21:31:23 +00:00
|
|
|
<img
|
|
|
|
class="mx-auto my-0 rounded-md"
|
|
|
|
src="{{ $url.String }}"
|
|
|
|
alt="{{ $altText }}"
|
2023-05-26 21:37:02 +00:00
|
|
|
{{ if $lazyLoad }}
|
2023-05-26 21:31:23 +00:00
|
|
|
loading="lazy"
|
|
|
|
{{ end }}
|
|
|
|
/>
|
2023-01-13 00:41:28 +00:00
|
|
|
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
|
2022-03-07 22:51:19 +00:00
|
|
|
</figure>
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ end }}
|
2022-01-12 03:21:22 +00:00
|
|
|
{{ end }}
|