Skip to content

Commit

Permalink
Use preview for unsupported images (fix nextcloud#1408)
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
  • Loading branch information
pulsejet committed Oct 10, 2022
1 parent ba57ec6 commit 48fb2df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ export default {
return this.getBase64FromImage()
}
if (this.source) {
return this.source
}
if (this.mime === 'image/gif') {
// Use original file if directly supported by the browser
const nativeMimes = ['image/apng', 'image/avif', 'image/jpeg', 'image/png', 'image/webp', 'image/gif']
if (this.src && nativeMimes.indexOf(this.mime) !== -1) {
return this.src
}
return this.previewPath
},
},
Expand Down
8 changes: 1 addition & 7 deletions src/mixins/PreviewUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default {
previewPath() {
return this.getPreviewIfAny({
fileid: this.fileid,
source: this.source,
filename: this.filename,
hasPreview: this.hasPreview,
davPath: this.davPath,
Expand All @@ -60,17 +59,12 @@ export default {
*
* @param {object} data destructuring object
* @param {string} data.fileid the file id
* @param {?string} data.source the download source
* @param {boolean} data.hasPreview have the file an existing preview ?
* @param {string} data.davPath the absolute dav path
* @param {string} data.filename the file name
* @return {string} the absolute url
*/
getPreviewIfAny({ fileid, source, filename, hasPreview, davPath }) {
if (source) {
return source
}

getPreviewIfAny({ fileid, filename, hasPreview, davPath }) {
const searchParams = `fileId=${fileid}`
+ `&x=${Math.floor(screen.width * devicePixelRatio)}`
+ `&y=${Math.floor(screen.height * devicePixelRatio)}`
Expand Down

0 comments on commit 48fb2df

Please sign in to comment.