Server: Image preview in sharing page should show the full image

Created on 22 Dec 2017  路  12Comments  路  Source: nextcloud/server

In the sharing page (go to the Files app, open the right sidebar for a file, open the _Sharing_ tab, click on _Share link_ and open that link in the browser) generally a download button is shown below the preview of the shared file. That button is hidden when the preview URL and the download URL are different, that is, when the shared file is an image. In this case clicking on the preview of the shared file directly shows the full preview of the image in the browser itself, without triggering a download and without showing the rest of elements of the page. The preview URL is used too in the _Direct link_ shown in the menu of the sharing page.

The problem is that when the full preview is generated its size ends limited to certain maximum value, even if the preview is requested with a width and height of -1. If the image is larger than the maximum preview size then a scaled down version instead of the full image would be shown. This is specially bad when the image is a rectangle with a large width and a small height or vice versa (for example, if you are sharing a screenshot of a full "tall" web page like https://nextcloud.com/news/); from a user point of view it just seems broken to click on the preview of the image in the sharing page and get a larger preview but still not a full image.

An option would be to either show the full preview of the image or directly download it based on the size of the image. If the image is smaller than the maximum preview size, then preview it. If not, then use the downloadURL as the previewURL, which would cause the download button to be shown, the download URL to be shown as the _Direct link_, and the image to be downloaded when clicking on its preview. However it could be confusing for users that sometimes an image is previewed and sometimes it is downloaded (although I think that it would still be better than the current behaviour).

In my opinion the proper behaviour would be to show the full image when accessing the preview URL of a shared image. The only difference between the download URL and the preview URL in this case would be in the headers returned on the HTTP response, which would cause the browser to either download or directly show the image.

Requesting the download URL and then altering the headers through JavaScript to make the browser show the image instead of downloading it is not a valid solution, not only because it would be a dirty hack :-P , but because it would apply when clicking on the preview, but not when accessing the direct link.

This should be solved on the server, either by extending the preview API (which would probably be complex) or by changing the implementation of directLink in PublicPreviewController, which is the method called when the preview URL is used, and which I suppose that would be easier; cc'ing @rullzer as the author of #6599 :-)

@nextcloud/designers Thoughts on all this?

3. to review bug design sharing help wanted

All 12 comments

@jancborchardt you wanted to change it to the preview if I remember correctly.

Ok so a bit of background. Before (when the button was below) this was maybe easier.

Previews are always limited in size. (see config.php). The reason for this is that we don't want to generate previews of 20kx20k for huge images etc.

The thing is if we redirect to the download link it will not show he image just download it. However if you click on the download link it will still properly download it.

I think the reason this behaviour was chosen was so that if people click on the image and just copy the url. It will work properly if they post that to some forum. We server that via a special route that does not do samesite cookie checks etc.

However, this is not the case for the download link. Note that I won't change the behaviour for the download link. That will send you the file (not display it) and it will have to be protected by the samesitecookie middleware.

Anyway, I don't have a real fix. But this is the reason why.

I just installed NC 13 beta 3.
Trying to figure out, how to use preview links.
I think, my issues are in scope of this issue, but if not - let me know that I should open separate issue.

1) Using "Files", I clicked "Share -> Share link" for image file. I'm getting this share link: https://nc.slavikf.com/index.php/s/x4xXjb9BXif7Dy8

  • GOOD: That link opens HTML page with image.
  • BAD: There is "Download link" on top of the page and it doesn't work. There is no way to download fullsize original image.
  • GOOD: From the HTML page, I can click on the image and it will open 2k preview directly in the browser (by adding /preview).
  • Would be really nice: if I would have option to choose size of the preview. Is it possible?

2) Using "Files", I'm clicking on the image - it shown. Now I click on the "Share" (top of the page icon) and get this link: https://nc.slavikf.com/index.php/apps/gallery/s/x4xXjb9BXif7Dy8

  • BAD: The image downloaded. It should be shown in browser, not downloaded For download we have another icon (Download arrow).
  • Would be nice to have option to choose, if I want Preview of Full size. Currently, image downloaded full size (6.7MB, 5k x 3k).
  • BAD: There is "Download link" on top of the page and it doesn't work. There is no way to download fullsize original image.

Already fixed in master

  • Would be really nice: if I would have option to choose size of the preview. Is it possible?

Not currently.

2) Using "Files", I'm clicking on the image - it shown. Now I click on the "Share" (top of the page icon) and get this link: https://nc.slavikf.com/index.php/apps/gallery/s/x4xXjb9BXif7Dy8

  • BAD: The image downloaded. It should be shown in browser, not downloaded For download we have another icon (Download arrow).
  • Would be nice to have option to choose, if I want Preview of Full size. Currently, image downloaded full size (6.7MB, 5k x 3k).

Please report that to the gallery app: https://github.com/nextcloud/gallery

Ok I'm not sure if I understand. Here's the simplified version of what should happen:

  • The link with the Nextcloud header etc should show the image preview, so reduced in file size. Yes this currently looks bad for images which are very tall and we need to fix this.
  • Tapping on the image should show the raw image, full format and file size.

Tapping on the image should show the raw image, full format and file size.

No. The behavior before was to download the image. And for good reasons. Now it just opens the preview. Which is also fine with me. However, we will not show the full image there.

  1. People will link to that image to include it on websites. This is not supported and will fail with the same site cookie check. We only allow hotlinking to the <url>/preview image
  2. We only serve in browser stuff that is processed by us.

    • The previews are generated

    • The full image could have malicious side effects

The behavior was never to download the image when tapping on it.
Remember people nowadays are on mobile so downloading does not make a whole lot of sense when receiving a share, viewing with zoom is more important.

Can we make it so then that when tapping, the full image processed by us will be loaded? So then people can see it bigger.

@jancborchardt ah you are right it was never download. There was no link on the image. Well that is until you added the link to download to it ;) See: https://github.com/nextcloud/server/pull/6652/files#diff-f2e13306e758275374ea68815da8af04R119

We won't show the full image here. Because that would mean we have to fully process (and store) each image. So you effectively duplicate your used storage. And it adds the issue that you still download a 30 mb picture.

What i think might make sense here:

  1. Remove the download link (so tap to zoom works again)
  2. With increasing screen resolutions etc. We should increase the default max preview size to 4k by 4k.

Huh, initially the click to view full size worked though? Must have been a subsequent change.

Both your suggestions on how to go forward are good! :)

PR to increase the preview size in https://github.com/nextcloud/server/pull/7731

PR to bring back touch to zoom in https://github.com/nextcloud/server/pull/7734

We have a bigger default preview now. I think this should solve most of the issues. If not then we have to think how to do this properly in some later release.

Was this page helpful?
0 / 5 - 0 ratings