4

Is it possible to make the uploaded "original" images unaccessable for site visitors and make only the transforms public?

I'd like to upload images in full quality, to

  1. get the best possible quality out of Craft transforms
  2. make Craft's assets folder basically a backup for my Lighroom library
  3. no manual transforms necessary before upload (Craft does the job anyways for all the required 2x, 1x and thumbnail sizes)

The images should be secure in that folder, otherwise I run into possible copyright problems (images would be in printable size and quality).

2

Since all asset transforms are saved in a sub-directory starting with an underscore, you could simply test for that.

Original:
/assets/folder/house.png

Transforms:
/assets/folder/_900x500/house.png
/assets/folder/_thumb/house.png

Plugin:

If your asset-folder is above public_html, and the request is routed through Craft, you could create a plugin, which checks for the underscore:

public function init()
{
    parent::init();

    //Is resource request?
    if (craft()->request->isResourceRequest()) {

        //Parent directory
        $parent_dir = dirname(craft()->request->getUrl());

        //Check if parent dir doesn't beginns with an underscore
        if (!preg_match('/^[\/\\]*([_]+)/U', $parent_dir)) {
            exit(403);
        }
    }
}

.htaccess:

If your assets can be accessed directly, you'd have to use .htaccess to deny the request. I'm really bad at RewriteConditions, so this would possible be a question for StackOverflow.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.