Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"nextcloud-server": "^0.15.9",
"nextcloud-vue": "^0.8.0",
"vue": "^2.6.7",
"vue-async-computed": "^3.6.1",
"xml2js": "^0.4.19"
},
"browserslist": [
Expand Down
31 changes: 29 additions & 2 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<template>
<img
:src="path"
:src="data"
:style="{
height: height + 'px',
width: width + 'px'
Expand All @@ -32,19 +32,46 @@

<script>
import mime from 'Mixins/Mime'
import axios from 'axios'
import Vue from 'vue'
import AsyncComputed from 'vue-async-computed'

Vue.use(AsyncComputed)

export default {
name: 'Videos',
mixins: [
mime
],
asyncComputed: {
data() {
if (this.mime !== 'image/svg+xml') {
return this.path
}
return this.getBase64FromImage()
}
},
methods: {
updateImgSize() {
const naturalHeight = this.$el.naturalHeight
const naturalWidth = this.$el.naturalWidth
this.updateHeightWidth(naturalHeight, naturalWidth)
// displaying tiny images makes no sense,
// let's try to an least dispay them at 100x100
this.updateHeightWidth(
Math.max(naturalHeight, 100),
Math.max(naturalWidth, 100)
)

this.doneLoading()
},
/**
* Manually retrieve the path and return its base64
*
* @returns {String}
*/
async getBase64FromImage() {
const file = await axios.get(this.path)
return `data:${this.mime};base64,${btoa(file.data)}`
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/models/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default {
'image/jpeg',
'image/gif',
'image/x-xbitmap',
'image/bmp'
'image/bmp',
'image/svg+xml'
],
component: Images
}