yandere_fe/src/components/link-preview/link-preview.js

36 lines
763 B
JavaScript
Raw Normal View History

2019-01-27 05:47:30 -08:00
const LinkPreview = {
name: 'LinkPreview',
props: [
2019-01-27 12:33:36 -08:00
'card',
'size',
'nsfw'
],
data () {
return {
imageLoaded: false
}
},
2019-01-27 12:33:36 -08:00
computed: {
useImage () {
// Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid
// as it makes sure to hide the image if somehow NSFW tagged preview can
// exist.
return this.card.image && !this.nsfw && this.size !== 'hide'
},
useDescription () {
return this.card.description && /\S/.test(this.card.description)
}
},
created () {
if (this.useImage) {
const newImg = new Image()
newImg.onload = () => {
this.imageLoaded = true
}
newImg.src = this.card.image
}
2019-01-27 12:33:36 -08:00
}
2019-01-27 05:47:30 -08:00
}
export default LinkPreview