Skip to content

Commit

Permalink
fallback to default skin on error
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed May 6, 2021
1 parent 865c4fe commit 036225b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Binary file added src/assets/defaultskin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/components/Avatar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<template>
<img
:src="`https://crafthead.net/helm/${key}`"
:src="`https://crafthead.net/helm/${key}/8`"
:title="title && `${name}'s avatar`"
@error="replaceWithDefault"
/>
</template>

<script>
import defaultSkin from '../assets/defaultskin.png';
export default {
props: {
id: {
Expand All @@ -24,5 +27,10 @@ export default {
return this.id.replace(/-/g, '');
},
},
methods: {
replaceWithDefault(e) {
e.target.src = defaultSkin;
},
},
};
</script>

0 comments on commit 036225b

Please sign in to comment.