Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Try using the public preview for relative image paths
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Sep 25, 2020
commit de50d70fbb1b8a6c9ebf54ad699451c55d1fc6e1
18 changes: 15 additions & 3 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,24 @@ export default {
if (this.hasPreviewUrl) {
return this.src
}
if (this.fileId) {
return generateUrl('/core/preview') + `?fileId=${this.fileId}&x=1024&y=1024&a=true`

const isPublic = document.getElementById('isPublic')?.value === '1'
const sharingToken = document.getElementById('sharingToken')?.value
const previewPath = (!isPublic ? generateUrl('/core/preview.png') : generateUrl('/apps/files_sharing/publicpreview/' + sharingToken))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the preview.png is what is breaking jpegs for the authenticated user.
Befor i had a 200 request for

http://nextcloud.local/index.php/core/preview?fileId=10&x=1024&y=1024&a=true

now i get a 400 for

http://nextcloud.local/index.php/core/preview.png?fileId=10&x=1024&y=1024&a=true
Suggested change
const previewPath = (!isPublic ? generateUrl('/core/preview.png') : generateUrl('/apps/files_sharing/publicpreview/' + sharingToken))
const previewPath = (!isPublic ? generateUrl('/core/preview') : generateUrl('/apps/files_sharing/publicpreview/' + sharingToken))


if (this.fileId && !isPublic) {
return previewPath + `?fileId=${this.fileId}&x=1024&y=1024&a=true`
}

if (isPublic) {
const f = FileList.getCurrentDirectory() + '/' + this.src.split('?')[0]
const pathParam = encodeURIComponent(path.normalize(f))
return previewPath + `?file=${pathParam}&x=1024&y=1024&a=true`
}

const f = FileList.getCurrentDirectory() + '/' + this.src
const pathParam = encodeURIComponent(path.normalize(f))
return generateUrl('/core/preview.png') + `?file=${pathParam}&x=1024&y=1024&a=true`
return previewPath + `?file=${pathParam}&x=1024&y=1024&a=true`
},
fileId() {
return getQueryVariable(this.src, 'fileId')
Expand Down