fix-featimage-ratio #127

Merged
paspo merged 4 commits from paspo/bglug.it:fix-featimage-ratio into main 2024-07-17 21:37:19 +00:00
3 changed files with 10 additions and 8 deletions

View File

@ -39,7 +39,3 @@
padding-right: 1em;
font-size: 1rem;
}
#content article img {
width: 100%;
}

View File

@ -3,7 +3,11 @@
{{- if not $u.IsAbs -}}
{{- $path := strings.TrimPrefix "./" $u.Path }}
{{- with or (.PageInner.Resources.Get $path) (resources.Get $path) -}}
{{- $src = (.Resize "1400x jpg q50").RelPermalink -}}
{{- if gt .Width 1400 -}}
{{- $src = (.Resize "1400x webp q50").RelPermalink -}}
{{- else -}}
{{- $src = (.Process "webp q50").RelPermalink -}}
{{- end -}}
{{- with $u.RawQuery -}}
{{- $src = printf "%s?%s" $src . -}}
{{- end -}}

View File

@ -26,10 +26,12 @@
<span class="image featured">
{{- if in $rasters $img.MediaType.SubType -}}
{{- $img = $img.Resize (printf "x%d" $maxHeight) -}}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" style="max-height: {{ $maxHeight }}px;" />
{{- if gt $img.Height $maxHeight -}}
{{- $img = $img.Resize (printf "x%d webp q50" $maxHeight) -}}
{{- end -}}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" {{- if gt $img.Height $img.Width -}}style="width: auto;"{{- end -}} />
{{ else }}
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" style="max-height: {{ $maxHeight }}px;" />
<img src="{{ $img.RelPermalink }}" alt="{{ .Params.image_alt }}" />
{{ end }}
</span>
{{ end }}