Flip PDF embed inside templates I have some 'Flip PDF' generated folders that I need only logged in users to be able to access. If I put them in templates I get the problem that the .jpg images 500. Is there a way of allowing .jpg images to be served from within the templates folder? This isn't as simple as using an 'internal assets' plugin and adding them manually as all of the flip pdf JS is created automatically and I don't want to have to edit it every time a new one needs to be uploaded.

I've searched high and low for the answer to this over the last few weeks as well as asking on slack but I've had no luck.

Edit: maybe there's a .htaccess file I can add in the template sub directory that will prevent images being loaded in the normal 'craft' way?

The folder structure looks like this:

craft
templates
    emag
        july-2018
            files
                mobile
                    *.jpg
                mobile-ext
                    *.jpg
                thumb
                    *.jpg
                    etc.
            mag
                javascript
                    *.js (loads fine)
                index.html &lt;--- the 'magazine' that needs the jpg's


The contents inside 'july-2018' is what the software gives me. All works fine, except for the .jpg images.
You'll need to create custom route to access those files. This is just an example of a custom route in my current module, so you need to find a pattern that matches the one you receive from the tool

$event-&gt;rules[] = [
    'pattern' =&gt; '/userfiles/&lt;fileType:\w+&gt;/&lt;fileName:\S+&gt;',
    'route'   =&gt; 'thaff/profile/get-file'
];


And your Controller action could be something like this

public function actionGetFile($view, $fileName)
{
    // create an alias to your folderpath $view should be thumb/mobile-ext or mobile depending on the route
    $localPath = Craft::getAlias('@yourFolderAlias') . DIRECTORY_SEPARATOR . $view;

    // you can include several checks if the image should be visible for the current user or not...

    $resp = Craft::$app-&gt;getResponse();
    $resp-&gt;headers-&gt;set('Content-Type' /*, insert your mime-type here */);
    $resp-&gt;format = Response::FORMAT_RAW;
    // check if the file exists
    if ($localPath &amp;&amp; file_exists($localPath . $fileName)) {
        // open the file
        $handle = fopen($localPath . $fileName, 'rb');
        // send the result to your response object
        $resp-&gt;stream = $handle;
        // send the response and close the file
        $resp-&gt;send();
        @fclose($handle);
    }
}


Note: this is just a little code snipped of my current project and I removed many conditional checks so it's easier to read.