lazy load comment author avatars and stamps

This commit is contained in:
perennial
2024-10-17 23:14:07 +11:00
parent 602d52051c
commit efbed98e2d
+3 -3
View File
@@ -46,10 +46,10 @@
{* checks whether .AuthorName is empty, indicating a deleted user *}
{{- if .AuthorName != "" }}
<a href="/users/{{ .AuthorID }}/bookmarks">
<img class="img-fluid rounded-circle object-fit-cover" src="{{ .Avatar }}" alt="{{ .AuthorName }}" style="width: 40px; height: 40px" />
<img class="img-fluid rounded-circle object-fit-cover" src="{{ .Avatar }}" alt="{{ .AuthorName }}" loading="lazy" style="width: 40px; height: 40px" />
</a>
{{- else }}
<img class="img-fluid rounded-circle object-fit-cover" src="{{ .Avatar }}" alt="{{ .AuthorName }}" style="width: 40px; height: 40px" />
<img class="img-fluid rounded-circle object-fit-cover" src="{{ .Avatar }}" alt="{{ .AuthorName }}" loading="lazy" style="width: 40px; height: 40px" />
{{- end }}
</div>
@@ -71,7 +71,7 @@
<!-- Stamp or emoji -->
<!-- TODO: .Stamp occasionally templates in text (which should be part of the main comment text) instead of an image, causing breakage in the layout. See the comment by "Unknown417" on /artworks/107442519 for an example -->
{{- if .Stamp }}
<img class="stamp img-fluid rounded object-fit-cover me-2" src="/proxy/s.pximg.net/common/images/stamp/generated-stamps/{{ .Stamp }}_s.jpg" alt="/proxy/s.pximg.net/common/images/stamp/generated-stamps/{{ .Stamp }}_s.jpg"/>
<img class="stamp img-fluid rounded object-fit-cover me-2" src="/proxy/s.pximg.net/common/images/stamp/generated-stamps/{{ .Stamp }}_s.jpg" alt="/proxy/s.pximg.net/common/images/stamp/generated-stamps/{{ .Stamp }}_s.jpg" loading="lazy" />
{{- else }}
<!-- Comment with emojis -->
<p class="d-flex flex-wrap align-items-center m-0">{{ raw: parseEmojis(.Context) }}</p>