feat: lazy load member avatars on user pages

This commit is contained in:
sam 2024-02-13 17:13:03 +01:00
parent 31e1862ca9
commit 4745a1c04b
No known key found for this signature in database
GPG key ID: B4EF20DDE721CAA1
2 changed files with 8 additions and 1 deletions

View file

@ -4,6 +4,7 @@
export let urls: string[];
export let alt: string;
export let width = 300;
export let lazyLoad = false;
const contentTypeFor = (url: string) => {
if (url.endsWith(".webp")) {
@ -31,6 +32,7 @@
src={urls[0] || defaultAvatars[0]}
{alt}
class="rounded-circle img-fluid"
loading={lazyLoad ? "lazy" : "eager"}
/>
</picture>
{:else}

View file

@ -46,7 +46,12 @@
<div>
<a href="/@{user.name}/{member.name}">
<FallbackImage urls={memberAvatars(member)} width={200} alt="Avatar for {member.name}" />
<FallbackImage
urls={memberAvatars(member)}
width={200}
lazyLoad
alt="Avatar for {member.name}"
/>
</a>
<p class="m-2">
<a class="text-reset fs-5 text-break" href="/@{user.name}/{member.name}">