nextcloud / nextcloud/server

Sharing direct link to image with specific size

Open
#16,239 18 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement feature: previews and thumbnails feature: sharing
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Hi!

I'm a new user of Nextcloud. I have been previously using Google Photos, where it is relatively easy to get a direct public link to a photo, in any size. I often used hotlinked images in forum posts, where it's convenient to use smaller size like 640 or 800 width.

In Nextcloud you can share the picture, and then append "/preview" to the url to get direct link to jpg file. This works, but gives full size.

I noticed that I can set the size in config.php:
'preview_max_x' => 400,
'preview_max_y' => 400,

Then the /preview image will be that size, which is promising! I could almost live with this, having single fixed size for my hotlinked images... BUT, now there is no way to access the original high resolution even when viewing the files in Nextcloud! Both "Files" and "Gallery" are now showing 400*400 version.

Could these be configured separately? To have big size for Files/Gallery and smaller size when sharing direct link?

After some testing, I noticed that that there actually IS an undocumented(?) public direct url to scaled images. An example:

shared image page:

https://zuik.org/nextcloud/index.php/s/wqTbdkTyDcMndwE

Direct "/preview" link, gives 1200*1600 image in this case:

https://zuik.org/nextcloud/index.php/s/wqTbdkTyDcMndwE/preview

However, by right clicking on the image in first page, you can copy that image's url, which is:

https://zuik.org/nextcloud/index.php/apps/files_sharing/publicpreview/wqTbdkTyDcMndwE?x=1920&y=512&a=true&file=32648662_1758604047533437_6548813824810549248_o.jpg&scalingup=0

Note there is x=1920&y=512 there which can be modified to give different values. You can also remove the file= token to make it shorter. The resulting url is still globally available and can be hotlinked, which I'm hopefully proving here:

test

Only certain sizes seem to be available, though. But perhaps they could be configured somehow? Also perhaps the photo html page could have direct buttons for many sized previews?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the publicpreview entry point at apps/files_sharing/publicpreview and reviewing how /preview uses preview_max_x and preview_max_y from config.php. Compare the behavior in the Files and Gallery views. Done should provide separately usable sizing for shared direct previews without reducing the high-resolution image shown in Nextcloud.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.