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

Make list of permanently saved preview thumbnails configurable #8196

Closed
butonic opened this issue Apr 14, 2014 · 5 comments
Closed

Make list of permanently saved preview thumbnails configurable #8196

butonic opened this issue Apr 14, 2014 · 5 comments

Comments

@butonic
Copy link
Member

butonic commented Apr 14, 2014

Depending on the installed apps preview thumbnails in various sizes are needed. Files needs 36x36, Pictures uses 200x200, Mobile and Tablets also need various sizes.

The current Preview thumbnail generation is quite flexible as you can specify the dimensons you want for the thumbnail. It will be scaled on the fly, which might take too long when the image is 10MB and no thumbnail is available.

The problem with caching ALL generated thumbnails is that it allows a malicious user to fill the disk by generating thumbs in 1000x1000, 1000x999, 1000x998 ... or even 100000x100000 when scaling up.

The current Implementation tries to prevent that by using the next bigger thumbnail to generate a thumbnail. If no Thumbnail exists it will use the original and save the thumbnail in the requested size. That has several drawbacks:

  1. if the first requested thumbnail is 1000x1000 no smaller thumbnails will be generated for that image.
  2. it still allows filling the disk by requesting 1000x1000, 1000x1001, 1000x1002 ...

I propose adding an optional configuration key to the config file like this:

'permanentPreviewSizes' => array(
    array('x' => 36, 'y' => 36),
    array('x' => 200, 'y' => 200),
    //TODO add mobile sizes
    array('x' => 1000, 'y' => 1000),
),

In addition the API should allow apps to add permanent thumbnail sizes. The Pictures app eg, could then use OCP\Config::addPermanentPreviewSize(200,200); Files could use OCP\Config::addPermanentPreviewSize(36,36); These calls would only add entries to the config array.

This would allow the next ™️ Photo editing app to add new custom thumbnail sizes.

The code generating the thumbnails could then check if the requested size matches a configured permanent size and cache the thumbnail if it does not exist, yet.

@georgehrke @DeepDiver1975 @icewind1991 what dou you think?

@georgehrke
Copy link
Contributor

makes sense,
one point about:

The problem with caching ALL generated thumbnails is that it allows a malicious user to fill the disk by generating thumbs in 1000x1000, 1000x999, 1000x998 ... or even 100000x100000 when scaling up.

We could furthermore remove the explicit exposure of width and height and replace it with smth like type=filelist which then maps to 32x32

e.g.
core/ajax/preview.png?file...&type=filelist instead of core/ajax/preview.png?file...&x=32&y=32

Apps could either register their own types or create their own preview.png

@icewind1991
Copy link
Contributor

We could furthermore remove the explicit exposure of width and height and replace it with smth like type=filelist which then maps to 32x32

The explicit width and height are used on high dpi screens to get the correct resolution previews

@RobinMcCorkell
Copy link
Member

Closing due to inactivity. If a better implementation is realized, please open a PR.

@MorrisJobke MorrisJobke removed this from the backlog milestone Oct 1, 2015
@oparoz
Copy link
Contributor

oparoz commented Nov 17, 2015

This is how MediaFire is doing it:
http://www.mediafire.com/developers/multimedia_api/images/

@lock
Copy link

lock bot commented Aug 7, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants