]> source.dussan.org Git - gitea.git/commitdiff
Lazy load avatar images (#32051) (#32063)
authorGiteabot <teabot@gitea.io>
Wed, 18 Sep 2024 08:52:44 +0000 (16:52 +0800)
committerGitHub <noreply@github.com>
Wed, 18 Sep 2024 08:52:44 +0000 (16:52 +0800)
Backport #32051 by @hiifong

Before:

https://github.com/user-attachments/assets/7b1681ba-4781-432a-ae20-c07e94c1dbb6

After:

https://github.com/user-attachments/assets/5154e160-e22c-460e-b0d9-28768486c178

Co-authored-by: hiifong <i@hiif.ong>
modules/templates/util_avatar.go

index 85832cf264cda4d6630bcccb172ce180cdd9447f..afc10915163bcfa989c70d883b169cadf05369ce 100644 (file)
@@ -34,7 +34,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
                name = "avatar"
        }
 
-       return template.HTML(`<img class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
+       return template.HTML(`<img loading="lazy" class="` + class + `" src="` + src + `" title="` + html.EscapeString(name) + `" width="` + sizeStr + `" height="` + sizeStr + `"/>`)
 }
 
 // Avatar renders user avatars. args: user, size (int), class (string)