From 95b735ff7244a44c61034be1c1e927f2fef3798e Mon Sep 17 00:00:00 2001
From: taehoon
Date: Sat, 2 Feb 2019 14:11:36 -0500
Subject: Show placeholder image if avatar image url is broken
---
src/components/user_avatar/user_avatar.js | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 src/components/user_avatar/user_avatar.js
(limited to 'src/components/user_avatar/user_avatar.js')
diff --git a/src/components/user_avatar/user_avatar.js b/src/components/user_avatar/user_avatar.js
new file mode 100644
index 00000000..bfa2c2b5
--- /dev/null
+++ b/src/components/user_avatar/user_avatar.js
@@ -0,0 +1,28 @@
+import StillImage from '../still-image/still-image.vue'
+import nsfwImage from '../../assets/nsfw.png'
+
+const UserAvatar = {
+ props: [
+ 'src'
+ ],
+ data () {
+ return {
+ showPlaceholder: false
+ }
+ },
+ components: {
+ StillImage
+ },
+ computed: {
+ imgSrc () {
+ return this.showPlaceholder ? nsfwImage : this.src
+ }
+ },
+ methods: {
+ imageLoadError () {
+ this.showPlaceholder = true
+ }
+ }
+}
+
+export default UserAvatar
--
cgit v1.2.3-70-g09d2