mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +01:00
feat: responsive avatar image size
This commit is contained in:
parent
2a18a92901
commit
8bb7025940
1 changed files with 14 additions and 3 deletions
|
@ -16,9 +16,20 @@
|
||||||
{{ $avatar := resources.Get (.src) }}
|
{{ $avatar := resources.Get (.src) }}
|
||||||
|
|
||||||
{{ if $avatar }}
|
{{ if $avatar }}
|
||||||
{{ $avatarResized := $avatar.Resize "300x" }}
|
{{ $avatarResized := $avatar.Resize "120x" }}
|
||||||
<img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
|
{{ $avatar1_5 := $avatar.Resize "180x" }}
|
||||||
height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
|
{{ $avatar2 := $avatar.Resize "240x" }}
|
||||||
|
<img
|
||||||
|
src="{{ $avatarResized.RelPermalink }}"
|
||||||
|
srcset="{{$avatarResized.RelPermalink}},
|
||||||
|
{{$avatar1_5.RelPermalink}} 1.5x,
|
||||||
|
{{$avatar2.RelPermalink}} 2x"
|
||||||
|
width="{{ $avatarResized.Width }}"
|
||||||
|
height="{{ $avatarResized.Height }}"
|
||||||
|
class="site-logo"
|
||||||
|
loading="lazy"
|
||||||
|
alt="Avatar"
|
||||||
|
/>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ errorf "Failed loading avatar from %q" . }}
|
{{ errorf "Failed loading avatar from %q" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue