Move a bunch of shortcodes and partials back from the platters theme

This commit is contained in:
Eryn Wells 2024-10-08 08:45:44 -07:00
parent 20d53e0df2
commit 3102dc1e56
29 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,9 @@
{{ $thumbnailResourcesNames := slice "thumbnail" "Thumbnail" "thumbnail.jpg" "Thumbnail.jpg" }}
{{ with index .Params "thumbnail" }}
{{ $thumbnailResourcesNames = $thumbnailResourcesNames | append . }}
{{ end }}
{{ $imageResources := .Resources.ByType "image" }}
{{ $photos := where $imageResources "Name" "not in" $thumbnailResourcesNames }}
{{ return $photos }}

View file

@ -0,0 +1,50 @@
{{/*
Renders a photo thumbnail. If neither a target height or target width are
given, and the image is already in the correct orientation, no image
processing is performed.
Arguments
---------
"Page" : A reference to the current Page
"Height" : The target height of the image
"Width" : The target width of the image
Returns
-------
The processed thumbnail image resource
*/}}
{{- $thumbnailResource := .Page.Resources.GetMatch
(index .Page.Params "thumbnail" | default "[tT]humbnail*")
| default (index (.Page.Resources.ByType "image") 0) -}}
{{- if not $thumbnailResource -}}
{{- errorf "No thumbnail available for %s" .Page.Permalink }}
{{- end -}}
{{ $orientation := partial "image-utilities/orientation-angle.html" $thumbnailResource }}
{{ $targetWidth := 0 }}
{{ with .Width }}
{{ $targetWidth = . }}
{{ else }}
{{ $targetWidth = $thumbnailResource.Width }}
{{ end }}
{{ $targetHeight := 0 }}
{{ with .Height }}
{{ $targetHeight = . }}
{{ else }}
{{ $targetHeight = $thumbnailResource.Height }}
{{ end }}
{{ $thumbnail := false }}
{{ if not (and (eq $orientation 0)
(eq $targetWidth $thumbnailResource.Width)
(eq $targetHeight $thumbnailResource.Height)) }}
{{ $thumbnail = $thumbnailResource.Fit (printf "%dx%d r%d" $targetWidth $targetHeight (sub 360 $orientation)) }}
{{ else }}
{{ $thumbnail = $thumbnailResource }}
{{ end }}
{{ return $thumbnail }}