Skip to content

Conversation

@juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Sep 25, 2020

Follow up to #1057 to make sure inserted images are accessible if they are in the same or sub directory of a share link

@juliusknorr juliusknorr added enhancement New feature or request 2. developing labels Sep 25, 2020
@juliusknorr juliusknorr requested a review from azul September 25, 2020 08:39
@azul
Copy link
Contributor

azul commented Sep 27, 2020

I tested this as follows:

  • I created a folder public and moved one of the images from Media into it.
  • I inserted the image into Readme.md via the workspace menu bar.
  • The image shows up fine on teh public share
  • However the image fails to show for the logged in user.

The relevant part of the html source for the logged in user looks like this

<div data-v-336b1e4e="" data-src="photo-1495962637988-4be9db2af01f.jpeg?fileId=10#mimetype=image%2Fjpeg&amp;hasPreview=true" class="image" contenteditable="false" draggable="true">
  <div data-v-336b1e4e="" class="image__placeholder">
    <div data-v-336b1e4e="" class="image__main" style="">
      <a data-v-336b1e4e="" href="/index.php/f/10" target="_blank">
        <div data-v-336b1e4e="" class="icon-image" style="background-image: url(&quot;/index.php/apps/theming/img/core/filetypes/image.svg?v=0&quot;);"></div> 
        <!---->
      </a>
    </div>
    <div data-v-336b1e4e="" class="image__caption" style="">
      <input data-v-336b1e4e="" type="text">
    </div>
  </div>
</div>

So it looks like we ended up in the placeholder branch of the template. The main branch has
v-if="imageLoaded && isSupportedImage".
So either imageLoaded or isSupportedImage is false.

I suspect that imageLoaded does not turn true because for an authenticated user the shareToken remains unset and the image cannot be loaded without it.

Copy link
Contributor

@azul azul left a comment

Choose a reason for hiding this comment

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

With the one adjustment mentioned above this works for me.

the imageUrl function is getting a bit complex and repetetive towards the end.
I suspect replacing the temp previewPath and f with a query / computed property would help here.

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))

@juliusknorr juliusknorr added this to the Nextcloud 24 milestone Jan 11, 2022
@juliusknorr
Copy link
Member Author

Obsolete through #1900

@juliusknorr juliusknorr deleted the bugfix/public-link-images-part2 branch January 14, 2022 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants