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 }}
|
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 08:07:09 +00:00
|
|
|
{{ if ne .MediaType.SubType "svg" }}
|
|
|
|
{{ $lqip := .Resize "20x webp" }}
|
|
|
|
<div class="mx-auto my-0 rounded-md"
|
|
|
|
style="background: url(data:image/webp;base64,{{ $lqip.Content | base64Encode }}); background-size: cover">
|
|
|
|
{{ end }}
|
2023-01-13 00:41:28 +00:00
|
|
|
<img
|
|
|
|
class="mx-auto my-0 rounded-md"
|
2023-01-14 23:38:53 +00:00
|
|
|
{{ if eq .MediaType.SubType "svg" }}
|
2023-01-13 00:41:28 +00:00
|
|
|
src="{{ .RelPermalink }}"
|
|
|
|
{{ else }}
|
2023-09-11 06:23:22 +00:00
|
|
|
width="{{ .Width }}"
|
|
|
|
height="{{ .Height }}"
|
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-13 00:41:28 +00:00
|
|
|
{{ end }}
|
|
|
|
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
|
|
|
/>
|
2023-09-11 08:07:09 +00:00
|
|
|
{{ if ne .MediaType.SubType "svg" }}
|
|
|
|
</div>
|
|
|
|
{{ end }}
|
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 }}
|