2024-07-27 22:59:43 +00:00
|
|
|
<figure>
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- $u := urls.Parse .Destination -}}
|
|
|
|
{{- $src := $u.String -}}
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- $figcaption := .Title | markdownify -}}
|
|
|
|
{{- $captionWidth := 0 -}}
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- if not $u.IsAbs -}}
|
|
|
|
{{- $path := strings.TrimPrefix "./" $u.Path }}
|
|
|
|
{{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
|
2024-07-17 21:37:18 +00:00
|
|
|
{{- if gt .Width 1400 -}}
|
|
|
|
{{- $src = (.Resize "1400x webp q50").RelPermalink -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $src = (.Process "webp q50").RelPermalink -}}
|
|
|
|
{{- end -}}
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- with $u.RawQuery -}}
|
|
|
|
{{- $src = printf "%s?%s" $src . -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- with $u.Fragment -}}
|
|
|
|
{{- $src = printf "%s#%s" $src . -}}
|
|
|
|
{{- end -}}
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- $captionWidth = .Width -}}
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2024-08-11 18:33:06 +00:00
|
|
|
{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" .Text) -}}
|
2024-07-27 22:59:43 +00:00
|
|
|
<img
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- range $k, $v := $attributes -}}
|
|
|
|
{{- if $v -}}
|
|
|
|
{{- printf " %s=%q" $k $v | safeHTMLAttr -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}>
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- with $figcaption -}}
|
|
|
|
<figcaption
|
2024-07-28 09:43:59 +00:00
|
|
|
{{ with $captionWidth }} style="max-width: {{- . -}}px;"
|
2024-07-27 22:59:43 +00:00
|
|
|
{{- end -}}>{{- . -}}</figcaption>
|
|
|
|
{{- end -}}
|
|
|
|
</figure>
|
2024-07-16 07:53:53 +00:00
|
|
|
{{- /**/ -}}
|