Skip to content

Commit 036225b

Browse files
committed
fallback to default skin on error
1 parent 865c4fe commit 036225b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/assets/defaultskin.png

303 Bytes
Loading

src/components/Avatar.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<template>
22
<img
3-
:src="`https://crafthead.net/helm/${key}`"
3+
:src="`https://crafthead.net/helm/${key}/8`"
44
:title="title && `${name}'s avatar`"
5+
@error="replaceWithDefault"
56
/>
67
</template>
78

89
<script>
10+
import defaultSkin from '../assets/defaultskin.png';
11+
912
export default {
1013
props: {
1114
id: {
@@ -24,5 +27,10 @@ export default {
2427
return this.id.replace(/-/g, '');
2528
},
2629
},
30+
methods: {
31+
replaceWithDefault(e) {
32+
e.target.src = defaultSkin;
33+
},
34+
},
2735
};
2836
</script>

0 commit comments

Comments
 (0)