Skip to content

Commit

Permalink
getPreviewIfAny: Use physical pixel size for preview resolution
Browse files Browse the repository at this point in the history
Code was inspired by code in an MDN page (in the public domain)
https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio

getPreviewIfAny: extract queryParams to get preview

Signed-off-by: Robbert Gurdeep Singh <[email protected]>
Signed-off-by: Axel Pirek <[email protected]>
Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
  • Loading branch information
connection-reset authored and npmbuildbot-nextcloud[bot] committed Jun 5, 2021
1 parent 0ea0add commit 49b70c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

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

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

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/mixins/PreviewUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ export default {
* @returns {String} the absolute url
*/
getPreviewIfAny({ fileid, filename, hasPreview, davPath }) {
const searchParams = `fileId=${fileid}`
+ `&x=${Math.floor(screen.width * devicePixelRatio)}`
+ `&y=${Math.floor(screen.height * devicePixelRatio)}`
+ '&a=true'

if (hasPreview) {
// TODO: find a nicer standard way of doing this?
if (isPublic()) {
return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${fileid}&file=${encodeFilePath(filename)}&x=${screen.width}&y=${screen.height}&a=true`)
return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?file=${encodeFilePath(filename)}&${searchParams}`)
}
return generateUrl(`/core/preview?fileId=${fileid}&x=${screen.width}&y=${screen.height}&a=true`)
return generateUrl(`/core/preview?${searchParams}`)
}
return davPath
},
Expand Down

0 comments on commit 49b70c6

Please sign in to comment.