在我的项目中,我在 web 根目录之外有一些受保护的图像。
在我的控制器中,我创建了一个返回 a 的路由,其中BinaryFileResponse
包含我要显示的图像的内容:
/**
* @Route("/protected/images/{filename}", name="protected_image")
*/
public function getProtectedimage($filename)
{
//.. logic ..
return new BinaryFileResponse($path);
}
在我的模板中,我使用 Twigpath()
来渲染该路线并显示图像:
<img src="{{ path('protected_image',{filename: myEntity.imagePath}) }}">
现在,我想将该路由与LiipImagine
应用filter
和创建缩略图一起使用,如下所示:
<img src="{{ path('protected_image',{filename: myEntity.imagePath}) | imagine_filter('my_thumb_filter') }}">
问题:总是显示损坏的图像和Source image not found in ..
日志。
我可以LiipImagine
与返回的路线一起使用BinaryFileResponse
吗?如果是这样,怎么做?