Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image preview in sharing page should show the full image #7614

Closed
danxuliu opened this issue Dec 22, 2017 · 12 comments
Closed

Image preview in sharing page should show the full image #7614

danxuliu opened this issue Dec 22, 2017 · 12 comments
Assignees
Labels
Milestone

Comments

@danxuliu
Copy link
Member

danxuliu commented Dec 22, 2017

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?

@danxuliu danxuliu added this to the Nextcloud 13 milestone Dec 22, 2017
@rullzer
Copy link
Member

rullzer commented Dec 23, 2017

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

@rullzer
Copy link
Member

rullzer commented Dec 23, 2017

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.

@SlavikCA
Copy link

SlavikCA commented Dec 26, 2017

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?
  1. 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).

@rullzer
Copy link
Member

rullzer commented Dec 28, 2017

  • 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.

  1. 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

@jancborchardt
Copy link
Member

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.

@rullzer
Copy link
Member

rullzer commented Jan 5, 2018

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

@jancborchardt
Copy link
Member

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.

@rullzer
Copy link
Member

rullzer commented Jan 6, 2018

@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.

@jancborchardt
Copy link
Member

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

@rullzer
Copy link
Member

rullzer commented Jan 8, 2018

PR to increase the preview size in #7731

@MorrisJobke MorrisJobke added the 3. to review Waiting for reviews label Jan 8, 2018
@rullzer
Copy link
Member

rullzer commented Jan 9, 2018

PR to bring back touch to zoom in #7734

@rullzer rullzer self-assigned this Jan 9, 2018
@rullzer
Copy link
Member

rullzer commented Jan 10, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants