diff --git a/frontend/src/lib/components/ui/avatar.svelte b/frontend/src/lib/components/ui/avatar.svelte index cab8227..61e8c13 100644 --- a/frontend/src/lib/components/ui/avatar.svelte +++ b/frontend/src/lib/components/ui/avatar.svelte @@ -7,6 +7,20 @@ }; let { src, class: klass }: Props = $props(); + + let valid_src = $state(false); + + $effect.pre(() => { + if (!src) { + valid_src = false; + return; + } + // create img instance + const img = new Image(); + img.onload = () => (valid_src = true); + img.onerror = () => (valid_src = false); + img.src = src; + });