Skip to content

Commit

Permalink
fix: align author image display size & actual size (hugo-sid#284)
Browse files Browse the repository at this point in the history
* fix: align image display size & actual size

* fix: use appropriate size

* fix: deal with displays densities

Use <img /> secret attribute to better expose display density-compliant images. Being the only image really showed in the entire theme, it deserves polish.
  • Loading branch information
cyrilmottier authored and weizhichuan committed Mar 5, 2025
1 parent c315e42 commit 3c621eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions layouts/partials/bio.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
<image width="25em" height="25em" href="{{ $image.RelPermalink }}" />
</svg>
{{ else }}
{{ $image := $image.Fill "100x100 webp" }}
<img class="author-avatar" src="{{ $image.RelPermalink }}" alt="{{ $avatar_img_alt }}" width="{{ .Width }}"
height="{{ .Height }}" />
{{ $image1x := $image.Fill "70x70 webp" }}
{{ $image2x := $image.Fill "140x140 webp" }}
{{ $image3x := $image.Fill "210x210 webp" }}
<img
class="author-avatar"
src="{{ $image1x.RelPermalink }}"
srcset="{{ $image2x.RelPermalink }} 2x, {{ $image3x.RelPermalink }} 3x"
alt="{{ $avatar_img_alt }}"
width="{{ $image1x.Width }}"
height="{{ $image1x.Height }}" />
{{ end }}
{{ end }}
<h2 class="author-name">{{ .Site.Params.author.intro }}</h2>
Expand Down

0 comments on commit 3c621eb

Please sign in to comment.