diff --git a/themes/2026/layouts/_partials/article-header.html b/themes/2026/layouts/_partials/article-header.html index 56e40eb2..3697320a 100644 --- a/themes/2026/layouts/_partials/article-header.html +++ b/themes/2026/layouts/_partials/article-header.html @@ -71,8 +71,12 @@ {{- $coverImage = $page.Resources.GetMatch $coverPath -}} {{- if $coverImage -}} {{- $coverDisplay = $coverImage -}} - {{- if and (ne $coverDisplay.MediaType.SubType "svg") (gt $coverDisplay.Width 1480) -}} - {{- $coverDisplay = $coverImage.Resize "1480x" -}} + {{- if ne $coverDisplay.MediaType.SubType "svg" -}} + {{- $coverWidth := $coverDisplay.Width -}} + {{- if gt $coverDisplay.Width 1480 -}} + {{- $coverWidth = 1480 -}} + {{- end -}} + {{- $coverDisplay = $coverImage.Resize (printf "%dx webp q80" $coverWidth) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/themes/2026/layouts/_partials/media/display-img.html b/themes/2026/layouts/_partials/media/display-img.html new file mode 100644 index 00000000..95d920f3 --- /dev/null +++ b/themes/2026/layouts/_partials/media/display-img.html @@ -0,0 +1,28 @@ +{{- $image := .image -}} +{{- $showMeta := .showMeta -}} +{{- $forceCentered := .forceCentered -}} +{{- $alt := .alt -}} +{{- $title := .title -}} +{{- $display := $image -}} + +{{- if ne $image.MediaType.SubType "svg" -}} + {{- if gt $image.Width $image.Height -}} + {{- $maxWidth := 1400 -}} + {{- if and $showMeta (not $forceCentered) -}} + {{- $maxWidth = 900 -}} + {{- end -}} + {{- $targetWidth := $image.Width -}} + {{- if gt $image.Width $maxWidth -}} + {{- $targetWidth = $maxWidth -}} + {{- end -}} + {{- $display = $image.Resize (printf "%dx webp q80" $targetWidth) -}} + {{- else -}} + {{- $targetHeight := $image.Height -}} + {{- if gt $image.Height 900 -}} + {{- $targetHeight = 900 -}} + {{- end -}} + {{- $display = $image.Resize (printf "x%d webp q80" $targetHeight) -}} + {{- end -}} +{{- end -}} + +{{ $alt }} diff --git a/themes/2026/layouts/_partials/media/render-image.html b/themes/2026/layouts/_partials/media/render-image.html index 0ec89ee6..dc92f083 100644 --- a/themes/2026/layouts/_partials/media/render-image.html +++ b/themes/2026/layouts/_partials/media/render-image.html @@ -13,10 +13,6 @@ {{- if not $image -}} {{- return -}} {{- end -}} -{{- $display := $image -}} -{{- if and (ne $display.MediaType.SubType "svg") (gt $display.Height 810) -}} - {{- $display = $image.Resize "x810" -}} -{{- end -}} {{- $metaTitle := index $data "title" -}} {{- $hasMeta := or $metaTitle (or $description (or $data.attribution $data.prompt)) -}} {{- $attributes := .Attributes | default dict -}} @@ -56,7 +52,13 @@ {{- end -}}
- {{ $alt }} + {{- partial "media/display-img.html" (dict + "image" $image + "showMeta" $showMeta + "forceCentered" $forceCentered + "alt" $alt + "title" $title + ) -}} {{- if $showMeta -}}
diff --git a/themes/2026/layouts/_shortcodes/extimage.html b/themes/2026/layouts/_shortcodes/extimage.html index 587af7ce..9d9ff913 100644 --- a/themes/2026/layouts/_shortcodes/extimage.html +++ b/themes/2026/layouts/_shortcodes/extimage.html @@ -8,11 +8,16 @@ {{- $extension := path.Ext $remoteURL -}} {{- $cleanFilename := printf "%s%s" $hash $extension | replace "?raw=true" "" -}} {{- $localImage := $remoteImage | resources.Copy (printf "remote-images/%s" $cleanFilename) -}} -{{- $resizedImage := $localImage.Resize "1024x" -}} {{- $hasMeta := or $title (or $description $attribution) -}}
- {{ $title }} + {{- partial "media/display-img.html" (dict + "image" $localImage + "showMeta" $hasMeta + "forceCentered" false + "alt" $title + "title" $title + ) -}} {{- if $hasMeta -}}