From 13a05b200bb39439418ad67fcbabe5102d3d28fb Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 21 Apr 2022 12:03:13 +0200 Subject: [PATCH] fix: image rendering via public previews Public Preview only has one route - it does not make use of the fileId. Signed-off-by: Max --- package/nodes/ImageView.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/package/nodes/ImageView.vue b/package/nodes/ImageView.vue index 3abe5e1622a..1bc7ba3e71a 100644 --- a/package/nodes/ImageView.vue +++ b/package/nodes/ImageView.vue @@ -215,16 +215,19 @@ export default { || this.src.startsWith('text://') }, previewUrl() { - const fileQuery = (this.imageFileId) - ? `?fileId=${this.imageFileId}&file=${encodeURIComponent(this.imagePath)}` - : `.png?file=${encodeURIComponent(this.imagePath)}` + const fileQuery = `file=${encodeURIComponent(this.imagePath)}` const query = fileQuery + '&x=1024&y=1024&a=true' - + if (getCurrentUser() && this.imageFileId) { + return generateUrl(`/core/preview?fileId=${this.imageFileId}&${query}`) + } if (getCurrentUser()) { - return generateUrl('/core/preview') + query - } else { - return generateUrl(`/apps/files_sharing/publicpreview/${this.token}${query}`) + return generateUrl(`/core/preview.png?${query}`) + } + if (this.token) { + return generateUrl(`/apps/files_sharing/publicpreview/${this.token}?${query}`) } + console.error('No way to authenticate image retrival - need to be logged in or provide a token') + return '' }, mime() { return getQueryVariable(this.src, 'mimetype')