diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Offer avatars at twice the size to dense screens
The 13 pixel icon came out blurred on the high density screens most
phones and laptops have.
Diffstat (limited to 'custom/extensions/email-libravatar.lua')
| -rw-r--r-- | custom/extensions/email-libravatar.lua | 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 11 insertions, 7 deletions
diff --git a/custom/extensions/email-libravatar.lua b/custom/extensions/email-libravatar.lua index e04c2c2..cc726de 100644 --- a/custom/extensions/email-libravatar.lua +++ b/custom/extensions/email-libravatar.lua @@ -34,10 +34,11 @@ local has_digest, digest = pcall(require, "openssl.digest") --- The size is in pixels and serves both as the image asked of the service --- and as the width and height attributes. The default image is what --- Libravatar draws for an address it has never seen. The endpoint is the --- secure CDN so the icon is not blocked as mixed content on an https page. +-- The size is in pixels and serves both as the image asked of the service and +-- as the width and height attributes, while a screen of double density is +-- offered an image twice the size. The default image is what Libravatar draws +-- for an address it has never seen. The endpoint is the secure CDN so the icon +-- is not blocked as mixed content on an https page. local avatar_size = 13 local default_image = "retro" local base_url = "https://seccdn.libravatar.org/avatar/" @@ -107,6 +108,10 @@ function filter_write(text) buffer = buffer .. text end +local function avatar_url(size) + return base_url .. avatar_hash .. "?s=" .. size .. "&d=" .. default_image +end + -- A log page can carry one icon per commit, so the attributes let the -- browser defer the fetches for icons still off screen and keep decoding -- off the critical path. The icon only decorates the name beside it, so its @@ -115,9 +120,8 @@ function filter_close() if avatar_hash == nil then html(buffer) else - html("<img src='" .. base_url .. avatar_hash .. - "?s=" .. avatar_size .. - "&d=" .. default_image .. + html("<img src='" .. avatar_url(avatar_size) .. + "' srcset='" .. avatar_url(avatar_size * 2) .. " 2x" .. "' alt='' width='" .. avatar_size .. "' height='" .. avatar_size .. "' loading='lazy' decoding='async'> " .. buffer) |
