freyjaskiss.com/layouts/shortcodes/imgproc.html

33 lines
1010 B
HTML
Raw Permalink Normal View History

2023-08-31 02:29:40 +00:00
{{- $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) -}}
{{- $image := $original -}}
{{- $align := "none" -}}
2023-08-31 03:21:35 +00:00
{{- $alttext := "" -}}
2023-08-31 02:29:40 +00:00
{{- with (.Get 1) -}}
{{- if not (eq . "auto") -}}
{{- if or (hasSuffix . "x") (hasPrefix . "x") -}}
2023-08-30 23:00:53 +00:00
{{ $image = ($image.Resize .) }}
2023-08-31 02:29:40 +00:00
{{- else -}}
2023-08-30 23:00:53 +00:00
{{ $image = ($image.Fit .) }}
2023-08-31 02:29:40 +00:00
{{- end -}}
{{- end -}}
{{- end -}}
{{- with (.Get 2) -}}
{{- $align = . -}}
{{- end -}}
2023-08-31 03:21:35 +00:00
{{- with (.Get 3) -}}
{{ $alttext = . -}}
{{- end -}}
2023-08-31 02:29:40 +00:00
{{- if (gt $image.Width 1500) -}}
{{- $image = ($image.Resize "1500x") -}}
{{- else if (gt $image.Height 1500) -}}
{{- $image = ($image.Resize "x1500") -}}
{{- end -}}
2023-08-31 03:21:35 +00:00
<figure style="float: {{ $align }};">
2023-08-31 02:29:40 +00:00
<a href="{{- $original.RelPermalink -}}">
2023-08-31 03:21:35 +00:00
<img style="max-width: 100%; width: auto; height: auto;" src="{{- $image.RelPermalink -}}" width="{{- $image.Width -}}" height="{{- $image.Height -}}" alt="{{ $alttext }}"/>
2023-08-30 23:00:53 +00:00
</a>
<figcaption>
{{ .Inner | markdownify }}
</figcaption>
</figure>