mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-21 18:11:37 +01:00
Label.logo: Generate a resize image
if the image is present in assets directory. - Resizing the image will reduce the size of a large image. - Should improve image load time. - Usage: - Add the image under assets directory. - Provide path in `label.icon`. - if image is located as `assets/images/image.png` mention `label.icon: images/image.png`.
This commit is contained in:
parent
566989abf4
commit
1de55c4266
@ -46,9 +46,31 @@
|
||||
{{- if site.Title }}
|
||||
<a href="{{ "" | absLangURL }}" accesskey="h" title="{{ $label_text }} (Alt + H)">
|
||||
{{- if site.Params.label.icon }}
|
||||
{{- $img := resources.Get site.Params.label.icon }}
|
||||
{{- if $img }}
|
||||
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
|
||||
{{- if hugo.IsExtended -}}
|
||||
{{- $processableFormats = $processableFormats | append "webp" -}}
|
||||
{{- end -}}
|
||||
{{- $prod := (hugo.IsProduction | or (eq site.Params.env "production")) }}
|
||||
{{- $imgUrl := "" }}
|
||||
{{- if and (in $processableFormats $img.MediaType.SubType) (eq $prod true)}}
|
||||
{{- if site.Params.label.iconHeight }}
|
||||
{{- $img = $img.Resize (printf "x%d" site.Params.label.iconHeight) }}
|
||||
{{ else }}
|
||||
{{- $img = $img.Resize "x30" }}
|
||||
{{- end }}
|
||||
{{- $imgUrl = $img.Permalink }}
|
||||
{{- else }}
|
||||
{{- $imgUrl = site.Params.label.icon | absURL }}
|
||||
{{- end }}
|
||||
<img src="{{ $imgUrl }}" alt="logo" aria-label="logo"
|
||||
height="{{- site.Params.label.iconHeight | default "30" -}}">
|
||||
{{- else }}
|
||||
<img src="{{- site.Params.label.icon | absURL -}}" alt="logo" aria-label="logo"
|
||||
height="{{- site.Params.label.iconHeight | default "30" -}}">
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $label_text -}}
|
||||
</a>
|
||||
{{- end }}
|
||||
|
Loading…
Reference in New Issue
Block a user