2018-01-29 18:47:26 +11:00
|
|
|
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: {
|
2018-02-04 03:55:45 +11:00
|
|
|
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
|
|
|
|
}
|
2018-01-29 18:47:26 +11:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2018-02-04 03:55:45 +11:00
|
|
|
onLoad () {
|
2018-01-29 18:47:26 +11:00
|
|
|
const canvas = this.$refs.canvas
|
|
|
|
if (!canvas) return
|
2018-02-04 03:55:45 +11:00
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|
2018-01-29 18:47:26 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default StillImage
|