blob: e674b93200af89eb9b3d8518dba51a9a9a40d45b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import fileTypeService from '../../services/file_type/file_type.service.js'
const StillImage = {
props: [
'src',
'referrerpolicy',
'mimetype'
],
data () {
return {
hideNsfwLocal: this.$store.state.config.hideNsfw,
}
},
computed: {
animated: {
get () {
// If mimetype is gif then it is certainly animated, if it's undefined - we don't know YET
return this.mimetype === 'image/gif' ? true : this.mimetype == null ? 'maybe' : false
},
set (val) {
this.mimetype = val
}
}
},
methods: {
onLoad () {
const canvas = this.$refs.canvas
if (!canvas) return
canvas.getContext('2d').drawImage(this.$refs.src, 1, 1, canvas.width, canvas.height)
if (this.animated === 'maybe') {
fetch(this.src).then((data) => {
console.log(data)
this.animated = data.type
})
}
}
}
}
export default StillImage
|