Skip to content

Commit 859e482

Browse files
connection-resetbackportbot[bot]
authored andcommitted
getPreviewIfAny: Use physical pixel size for preview resolution
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 <git@beardhatcode.be> Signed-off-by: Axel Pirek <axel.pirek@protonmail.com>
1 parent 0ea0add commit 859e482

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/mixins/PreviewUrl.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,17 @@ export default {
6363
* @returns {String} the absolute url
6464
*/
6565
getPreviewIfAny({ fileid, filename, hasPreview, davPath }) {
66+
const searchParams = `fileId=${fileid}`
67+
+ `&x=${Math.floor(screen.width * devicePixelRatio)}`
68+
+ `&y=${Math.floor(screen.height * devicePixelRatio)}`
69+
+ '&a=true'
70+
6671
if (hasPreview) {
6772
// TODO: find a nicer standard way of doing this?
6873
if (isPublic()) {
69-
return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${fileid}&file=${encodeFilePath(filename)}&x=${screen.width}&y=${screen.height}&a=true`)
74+
return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?file=${encodeFilePath(filename)}&${searchParams}`)
7075
}
71-
return generateUrl(`/core/preview?fileId=${fileid}&x=${screen.width}&y=${screen.height}&a=true`)
76+
return generateUrl(`/core/preview?${searchParams}`)
7277
}
7378
return davPath
7479
},

0 commit comments

Comments
 (0)