Show placeholder image if avatar image url is broken

This commit is contained in:
taehoon 2019-02-02 14:11:36 -05:00
parent 815b9d2391
commit 95b735ff72
6 changed files with 39 additions and 3 deletions

View file

@ -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