There should be a way to allow image style derivatives of private images to be stored on the public file system.

There are many situations one can think of, where one would like to keep the original photos private but does not bother to make derivatives of it private as well. Think of thumbnails; watermarked and scaled down versions; or scaled down derivatives with lower color depth.

Advantages would be that a full Drupal bootstrap is avoided for these derivatives and that there is no need to install contrib or custom access modules to handle access to these derivatives.

Risk is that people oversee that in doing so, ALL private images can be accessed via a public derivative as there is no way to restrict this to only images stored in some fields.

Original report

Hello,

I am using Drupal as a photo gallery purposes. During building up a site I ended up in deadlock, concerning permissions (public or private file system) of image files and derivatives of them for various purposes.

I explain the whole problem in module ImageCache Actions issues: http://drupal.org/node/1863720

In short, first I have requested a feature for ImageCache Actions, to be able to create any new derivatives of image with different file system than the original. But as the posts reveal, this leads to drupal core, probably file system (at least so I believe)?

This should solve a problem:

If I use private filesystem for images, also the (derivated) thumbnails are created to private filesystem, and that leads to a unnecessary performance issue, because all of the thumbnails involve "drupal bootstrap" before they are sent to the browser. That is a performance problem. Can't do.

If I use public filesystem for images, then all the images are.... public. Also the original, which _must_ be protected. Even if I use only derivated versions in webpage, the originals are still easily accessible by doing a little bit of URL hacking (just by cutting some characters off from the URL). And that is security problem. Can't do.

I am speaking of photo works with quite lot of hours invested to each of them, so it is really important thing to make sure the originals don't get leaked out from the site.

Now, what I am requesting, is something what you could offer for the module makers, concerning the selection between private and public filesystem, when module does some derivated version of file in node.

If you read the issue in the ImageCache Actions page above, I believe you will easily see what is the problem here. I believe it must be in file system part of Drupal, where should be some sort of possibility to select more carefully the permissions of the new, derivated version of a file.

Automated image handling processes are very important when trying to do well working photo gallery (for both the admin and the viewers).

I'm not a programmer at all, so I apologize if the request doesn't make any sense in technically speaking, but I hope you could read the explanation linked above.

Comments

fietserwin’s picture

Version: 7.19 » 8.x-dev
Component: file system » image system

+1.

However, new features go in the currently developed version first, backporting is only done if it doesn't change any API or interface text (which it will). I also think the issue belongs to the image system as AFAICS there is no real blocker in the file system that makes this impossible at the moment.

Solution:
All image styles should offer an option to let the user (i.e. the user that creates/edits the image style) decide where to store the derivatives: same file system as original OR always public file system. Always private seems a bit odd to me but can (should) be added for completeness. This option should then be passed to the theme function that creates the URL for derived images.

Storing this at the field level seems to be more logical, but that won't work as the image style subsystem has no knowledge of fields (and cannot have). Note that this thus will lead to opening all images to the public via image styles that use this new option to make derived images public. So people should be very very careful to use it, but still there are legitimate use cases for this feature.

potatosauce’s picture

To clarify the needs, the system should work so that the original image can be set in private file system securely and all the derived files from that can be set to public file system with max performance.

And please do have some eye also in URL hacking. If I remember right, also the private file system allows to URL hack the original file visible, if the visitor is allowed to view a derived version of it.

So, I think this is sort of thing depending on the permissions, which looks like to be always the same to all of the image files, original and all the derived versions.

This sounds sort of small thing, but to be able to have both security and performance, I had to set the site using 2 files, small imagefile without watermark for making thumbnails, and then bigger watermarked version to give a bigger view. Watermark is also done manually before uploading it to the site. Both files are in public file system. So it's sort of hindering down the possibilities, when it is not possible to use this great ImageCache Actions module just because of the filesystem permissions aren't allowing to more carefully select what is public and what is not.

Anyways, great job you're doing, Drupal just rocks!

fietserwin’s picture

File system permissions do allow to use any access system that suits you, but out of the box (core and contrib) there are only a few offered, and none of them seems to fit your use case. You could still implement your own, but that would not solve the performance problems.

URL hacking was what I was referring to in the last paragraph of #1.

potatosauce’s picture

Oh by the way, just to give an idea, this same thing about different permissions (or file system or something?) for the derived files could also work on variety of other needs too, so it doesn't necessarily concern only images. My particular case is just about images (and I will be happy as a clam to solve it :-), but you might think this also in viewpoint of making videos:

Full videofile only for people with permissions, and some automatically made few second clip of the original could be public.

Or... audio. Full MP3 file for people with permission to hear it and automatically derived few second file to public.

Or... pretty much any file, what is possible to be manipulated some way automatically to make a public preview versions out of the privately stored full file. Just what ImageCache Actions already does for images (excluding the permissions part), and would be better if the permission settings on derivatives could exist.

You could think the same thing vice versa too: having some big data file public, and some automatically made derivated smaller version of that file in private file system.

With these examples I just wanted to justify this feature proposition better by giving you an idea of wider range of practical solutions generally which could be enabled with this feature, if it is accepted to be done. It could be utilized by far more people than only image enthusiasts, and that would give the solution more robust footprint in the Drupal future.

potatosauce’s picture

Issue summary: View changes

Emphasized some words to better highlight the need of some differentiation in permissions between original file and any derivation of the original file.

fietserwin’s picture

Title: Image file derivatives need a way for selectable file system or somehow to better select permissions » Allow image style derivatives of private images to be stored on the public file system

Shorter title and issue description.

dman’s picture

A workable patch for exactly this looks to be taking shape now at #2027423: Make image style system flexible
(Probably a duplicate now, but I'll have to trial the patch to confirm this is actually,practically,technically the same issue before I flag that)

claudiu.cristea’s picture

Status: Active » Closed (duplicate)

While #2027423: Make image style system flexible already provides a patch and has aggregated all related issues let's mark this as duplicate and focus there to get this feature in core.

Marking this as duplicate of #2027423: Make image style system flexible.

claudiu.cristea’s picture

Issue summary: View changes

simplified issue report

josephdpurcell’s picture

josephdpurcell’s picture

Regarding being able to customize the scheme used for a particular image style (e.g. a watermark), see #1358896: Flexible scheme and URI for image derivatives.

bkosborne’s picture

I scanned through the reports, but I didn't see the specific use case mentioned of how it would be useful to have the original stored as a private file but the derivatives stored as public. What's the point of making the original file private at that point?

dman’s picture

The use-case is one I've encountered myself, and acknowledge that the lack of such an option is a weakness.

Quite simply, anyone who works with high-quality photography (or I guess any similar digital asset) will probably want to retain their high-resolution originals as 'private' files, while publishing versions to the public web that are downscaled and/or watermarked.

Although some folk may naively use the Drupal display system to not provide obvious access to the 'originals' anywhere, the URLs to the originals are trivial to reverse engineer with a public filesystem, and there is no mitigation against that.
Others, such as photography studios, who care about watermarking etc have had to run a pre-process that stamps their images *before* they upload to Drupal. That is not only a pointless pain (when the CMS can happily do that automatically with image effects), but it compromises the images because the thumbnails of those already-watermarked images end up with scaled down watermarks, which just looks awful.
I've worked with galleries of thousands of such images, and have been happy that the originals were available on the system when the day came to change the watermark globally, or to adjust the resize rules (and re-stamp) the preview images across everything.

Original, high-quality, raw, (possibly huge) image : private.
Derivate, preview, thumbnail or watermarked version, shrunk for the web: public.

fonant’s picture

I'd find this useful for a couple of customer sites.

Uploaded full-scale unwatermarked images: private
Derived small-scale and/or watermarked images: public

It's possible to modify the permissions system to give anonymous users access to private derived images for certain styles, but for a site with lots of images it's process-intensive to check permissions for every image. Much better to store the derived images in the public filesystem, so they can be served direct by the web server without needing to bootstrap Drupal for every one.

allie micka’s picture

FWIW This module accomplishes the private field -> public derivative use case: https://www.drupal.org/project/image_style_scheme