You could create a controller action to access files that are stored in a non public folder. In that action, you open file and stream in to browser.
See example at http://php.net/manual/en/function.readfile.php
You will need to change
header('Content-Disposition: attachment; filename='.basename($file));
to
header('Content-Disposition: inline; filename='.basename($file));
UPDATE:
When you have your controller action that would stream requested file, you can render it in your TWIG by requesting that action with required file identifier:
<img src="{{ path('route_to_stream_action', {'fileId':'some_id'}) }}">
Browser will treat streamed file the same way as if it was accessed directly, so you can apply any CSS to it.
UPDATE:
Sample controller action:
public function streamFileAction($fileId)
{
// implement your own logic to retrieve file using $fileId
$file = $this->getFile($fileId);
$filename = basename($file);
$response = new StreamedResponse();
$response->setCallback(function () use ($file){
$handle = fopen($file->getRealPath(), 'rb');
while (!feof($handle)) {
$buffer = fread($handle, 1024);
echo $buffer;
flush();
}
fclose($handle);
});
$d = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $filename);
$response->headers->set('Content-Disposition', $d);
$response->headers->set('Content-Type', $file->getMimeType());
return $response;
}