Show placeholder image if avatar image url is broken
This commit is contained in:
parent
815b9d2391
commit
95b735ff72
6 changed files with 39 additions and 3 deletions
28
src/components/user_avatar/user_avatar.js
Normal file
28
src/components/user_avatar/user_avatar.js
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue