2022-11-06 09:03:18 +00:00
|
|
|
{{- $context := .context }}
|
|
|
|
{{- $url := .url }}
|
|
|
|
{{- $title := .title }}
|
|
|
|
{{- $alt := .alt }}
|
2022-12-16 20:34:07 +00:00
|
|
|
{{- $classes := slice }}
|
2023-01-29 10:21:52 +00:00
|
|
|
{{- $lightbox := true }}
|
2022-11-06 15:26:11 +00:00
|
|
|
{{- $height := "auto" }}
|
|
|
|
{{- $width := "auto" }}
|
2022-11-06 09:03:18 +00:00
|
|
|
{{- $dest_url := urls.Parse $url }}
|
2022-11-18 23:23:02 +00:00
|
|
|
{{- $dest_path := $dest_url.Path }}
|
|
|
|
{{- $image := $context.Resources.GetMatch $dest_path }}
|
|
|
|
{{- if not $image }}
|
|
|
|
{{- $image = .Resources.GetMatch $dest_path }}
|
|
|
|
{{- end }}
|
|
|
|
{{- if not $image }}
|
|
|
|
{{- $image = .Resources.GetRemote $url }}
|
2022-11-06 15:26:11 +00:00
|
|
|
{{- end }}
|
2022-11-06 09:03:18 +00:00
|
|
|
{{- if $image }}
|
|
|
|
{{- $url = $image.RelPermalink }}
|
|
|
|
{{- if $dest_url.RawQuery }}
|
|
|
|
{{- $url = printf "%s?%s" $url $dest_url.RawQuery }}
|
|
|
|
{{- end }}
|
2022-11-06 15:26:11 +00:00
|
|
|
{{- end }}
|
|
|
|
{{- if $dest_url.RawQuery }}
|
2022-12-16 20:34:07 +00:00
|
|
|
{{- if $dest_url.Query.Get "classes" }}
|
|
|
|
{{- $classes = $classes | append (split ($dest_url.Query.Get "classes") ",") }}
|
|
|
|
{{- end }}
|
2023-01-29 10:21:52 +00:00
|
|
|
{{- $lightbox = and (ne ($dest_url.Query.Get "lightbox") "false") (ne ($dest_url.Query.Get "featherlight") "false") }}
|
2022-11-06 15:26:11 +00:00
|
|
|
{{- with $dest_url.Query.Get "height" }}
|
|
|
|
{{ $height = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- with $dest_url.Query.Get "width" }}
|
|
|
|
{{ $width = . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2023-05-17 20:55:34 +00:00
|
|
|
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
|
2023-01-29 10:21:52 +00:00
|
|
|
{{- if $lightbox }}
|
2023-02-04 15:17:19 +00:00
|
|
|
<a href="#image-{{ $id }}" class="lightbox-link">
|
2022-11-06 09:03:18 +00:00
|
|
|
{{- end }}
|
2022-12-16 20:34:07 +00:00
|
|
|
<img src="{{ $url | safeURL }}" alt="{{ $alt }}"{{ with $title }} title="{{ . }}"{{ end }}{{ if len ($classes) }} class="{{ delimit $classes " " }}"{{ end }} style="height: {{ $height }}; width: {{ $width }};" loading="lazy">
|
2023-01-29 10:21:52 +00:00
|
|
|
{{- if $lightbox }}
|
|
|
|
</a>
|
2023-02-02 22:45:31 +00:00
|
|
|
<a href="javascript:history.back();" class="lightbox" id="image-{{ $id }}">
|
2023-02-04 15:17:19 +00:00
|
|
|
<img src="{{ $url | safeURL }}" alt="{{ $alt }}"{{ with $title }} title="{{ . }}"{{ end }} class="lightbox-image" loading="lazy">
|
2022-11-06 15:26:11 +00:00
|
|
|
</a>
|
|
|
|
{{- end }}
|