Merge branch '631' into 'develop'

Hide image block in rich media preview in case of broken image

Closes #631

See merge request pleroma/pleroma-fe!902
このコミットが含まれているのは:
Shpuld Shpludson 2019-08-08 10:10:58 +00:00
コミット acb788d575
2個のファイルの変更15行の追加1行の削除

ファイルの表示

@ -5,6 +5,11 @@ const LinkPreview = {
'size', 'size',
'nsfw' 'nsfw'
], ],
data () {
return {
imageLoaded: false
}
},
computed: { computed: {
useImage () { useImage () {
// Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid // Currently BE shoudn't give cards if tagged NSFW, this is a bit paranoid
@ -15,6 +20,15 @@ const LinkPreview = {
useDescription () { useDescription () {
return this.card.description && /\S/.test(this.card.description) 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" rel="noopener"
> >
<div <div
v-if="useImage" v-if="useImage && imageLoaded"
class="card-image" class="card-image"
:class="{ 'small-image': size === 'small' }" :class="{ 'small-image': size === 'small' }"
> >