Skip to content

[Bug]: Direct links to image file shares using the /s/token/preview url suffix are tiny when using Imaginary #36865

@KenBW2

Description

@KenBW2

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

I got very used to sharing images over SMS and other means using Nextcloud URLs

On my previous NC 22 instance I could share the full resolution image using the share link

https://nextcloud-instance.com/s/XXXXXXXXXX/preview

As documented in apps/files_sharing/appinfo/routes.php

		[
			'name' => 'PublicPreview#directLink',
			'url' => '/s/{token}/preview',
			'verb' => 'GET',
			'root' => '',
		],

In NC 22 This would render in the browser a full resolution version of the picture

Since upgrading to NC 25 I found I only get a small 256 pixel version of the image

When disabling Imaginary I get a much more usable sized version of the image

images

I tracked down the code which makes this change in \OC\Preview\Generator::generatePreviews()

The call hierarchy is:

  • \OCA\Files_Sharing\Controller\PublicPreviewController::directLink()
    • \OC\PreviewManager::getPreview()
      • \OC\Preview\Generator::getPreview()
        • \OC\Preview\Generator::generatePreviews()
		// If imaginary is enabled, and we request a small thumbnail,
		// let's not generate the max preview for performance reasons
		if (count($specifications) === 1
			&& ($specifications[0]['width'] <= 256 || $specifications[0]['height'] <= 256)
			&& preg_match(Imaginary::supportedMimeTypes(), $mimeType)
			&& $this->config->getSystemValueString('preview_imaginary_url', 'invalid') !== 'invalid') {
			$crop = $specifications[0]['crop'] ?? false;
			$preview = $this->getSmallImagePreview($previewFolder, $file, $mimeType, $previewVersion, $crop);

			if ($preview->getSize() === 0) {
				$preview->delete();
				throw new NotFoundException('Cached preview size 0, invalid!');
			}

			return $preview;
		}

This is a new addition to the code between NC 22 and 25

If Imaginary is disabled it goes on to do it the old way - taking the $maxWidth variable (the $specifications passed into the method sends -1 as width and height)

		[$maxWidth, $maxHeight] = $this->getPreviewSize($maxPreview, $previewVersion);

		$preview = null;

		foreach ($specifications as $specification) {
			$width = $specification['width'] ?? -1;
			$height = $specification['height'] ?? -1;
			$crop = $specification['crop'] ?? false;
			$mode = $specification['mode'] ?? IPreview::MODE_FILL;

			// If both width and height are -1 we just want the max preview
			if ($width === -1 && $height === -1) {
				$width = $maxWidth;
				$height = $maxHeight;
			}

The code takes two different behaviours depending on if it's using Imaginary or not

A "directLink" should not be generating a getSmallImagePreview - it should be a direct link to the full image

Steps to reproduce

  1. Enable Imaginary
  2. Share an image file
  3. Suffix "/preview" to the share URL

Expected behavior

See the image in full resolution, as it was in Nextcloud 22

Instead I get a cropped 256x256 thumbnail

Installation method

Official All-in-One appliance

Operating system

Debian/Ubuntu

PHP engine version

None

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Updated to a major version (ex. 22.2.3 to 23.0.1)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

Enabled:
  - calendar: 4.2.3
  - cloud_federation_api: 1.8.0
  - contacts: 5.1.0
  - dav: 1.24.0
  - deck: 1.8.3
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - gpxpod: 5.0.4
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - mail: 2.2.2
  - maps: 0.2.4
  - nextcloud-aio: 0.3.0
  - notify_push: 0.6.0
  - oauth2: 1.13.0
  - password_policy: 1.15.0
  - photos: 2.0.1
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - related_resources: 1.0.3
  - richdocuments: 7.1.1
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - snappymail: 2.25.4
  - spreed: 15.0.4
  - support: 1.8.0
  - survey_client: 1.13.0
  - tasks: 0.14.5
  - text: 3.6.0
  - theming: 2.0.1
  - timetracker: 0.0.77
  - twofactor_backupcodes: 1.14.0
  - viewer: 1.9.0
  - workflowengine: 2.7.0

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions