我正在尝试对基于 LiipImagineBundle 的图像应用过滤器。
以下是步骤:
通过添加此行通过 composer 文件进行安装:
"liip/imagine-bundle": "1.0.*@dev"
通过添加以下行来配置 config.yml 文件:
liip_imagine: resolvers: default: web_path: web_root: %kernel.root_dir%/../web cache_prefix: media/cache filter_sets: cache: ~ my_thumb: quality: 75 filters: thumbnail: { size: [120, 90], mode: outbound }
AppKernel.php 中的 bundle 声明:
new Liip\ImagineBundle\LiipImagineBundle(),
通过在 twig 文件中添加一行来测试包:
<img src="{{ asset('img/test.jpg') | imagine_filter('my_thumb') }}" />
但是,没有显示图像。生成的 HTML 文件包含:
<img src="http://localhost/tuto/web/app_dev.php/media/cache/my_thumb/img/test.jpg">
在浏览器的 javascript 控制台中,我发现了这个错误:
GET http://localhost/tuto/web/app_dev.php/media/cache/my_thumb/img/test.jpg 500 (Internal Server Error)
当我尝试打开链接时(带有 500 Internal Server Error),symfony 抛出这个错误:
Failed to create /home/amine/NetBeansProjects/tuto/app/../web/media/cache/my_thumb/img
500 Internal Server Error - IOException
我想我没有创建以下文件夹的权限:/home/amine/NetBeansProjects/tuto/app/../web/media/cache/my_thumb/img
. 在我看来,自从我在 Ubuntu 上工作以来,这是可以预料的。
web
为了避免这个问题,我直接通过更改文件夹的权限,sudo chmod 777 -R web
但问题还是一样。
有什么想法吗?