Skip to content

Commit

Permalink
Merge pull request #1525 from nextcloud/enh/app-specific-preview-url
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Feb 1, 2023
2 parents 9169c09 + 4b6a2c2 commit 8aa4b64
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default {
// If there is no preview and we have a direct source
// load it instead
if (this.source && !this.hasPreview) {
if (this.source && !this.hasPreview && !this.previewUrl) {
return this.source
}
Expand Down
7 changes: 6 additions & 1 deletion src/mixins/Mime.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export default {
type: String,
default: undefined,
},
// file path relative to user folder
// URL the file preview
previewUrl: {
type: String,
default: undefined,
},
// should the standard core preview be used?
hasPreview: {
type: Boolean,
default: false,
Expand Down
8 changes: 7 additions & 1 deletion src/mixins/PreviewUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
return this.getPreviewIfAny({
fileid: this.fileid,
filename: this.filename,
previewUrl: this.previewUrl,
hasPreview: this.hasPreview,
davPath: this.davPath,
})
Expand All @@ -60,12 +61,17 @@ export default {
*
* @param {object} data destructuring object
* @param {string} data.fileid the file id
* @param {string} [data.previewUrl] URL of the file preview
* @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, filename, hasPreview, davPath }) {
getPreviewIfAny({ fileid, filename, previewUrl, hasPreview, davPath }) {
if (previewUrl) {
return previewUrl
}

const searchParams = `fileId=${fileid}`
+ `&x=${Math.floor(screen.width * devicePixelRatio)}`
+ `&y=${Math.floor(screen.height * devicePixelRatio)}`
Expand Down
1 change: 1 addition & 0 deletions src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Audios from '../models/audios.js'
* @property {string} basename the full path of the file
* @property {?string} source absolute path of a non-dav file, e.g. a static resource or provided by an app route
* @property {string} mime file MIME type in the format type/sub-type
* @property {string} [previewUrl] URL of the file preview
* @property {boolean} hasPreview is there a WebDAV preview of this file?
* @property {number} fileid Nextcloud file ID
*/
Expand Down

0 comments on commit 8aa4b64

Please sign in to comment.