Skip to content
Snippets Groups Projects
Commit bb9cee84 authored by Tae Hoon's avatar Tae Hoon
Browse files

hide rich media preview image in case of broken image

parent 17dc7357
No related branches found
No related tags found
2 merge requests!1028`master` refresh with `develop`,!902Hide image block in rich media preview in case of broken image
......@@ -5,6 +5,11 @@ const LinkPreview = {
'size',
'nsfw'
],
data () {
return {
imageLoaded: false
}
},
computed: {
useImage () {
// Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid
......@@ -15,6 +20,15 @@ const LinkPreview = {
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
}
}
}
......
......@@ -7,7 +7,7 @@
rel="noopener"
>
<div
v-if="useImage"
v-if="useImage && imageLoaded"
class="card-image"
:class="{ 'small-image': size === 'small' }"
>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment