我正在尝试使用LiipImagineBundle。
#app/config/confiy.yml
# liip_imagine Configuration
liip_imagine:
resolvers:
default:
web_path:
web_root: %kernel.root_dir%/../web
cache_prefix: media/cache
loaders:
default:
filesystem:
data_root: %kernel.root_dir%/../web/
#....
#...
filter_sets:
medium:
quality: 100
filters:
thumbnail: { size: [280, 280], mode: outbound }
#....
#...
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
upload_folder: "uploads/"
如果使用:
app/console liip:imagine:cache:resolve /uploads/photos/3/01.jpg --filters=medium
效果很好。
但使用后:
#src/Hy/PhotoBundle/Resources/views/Photo/index.html.twig
{% for entity in pagination %}
{% set photo=upload_folder~entity.fileManaged.uri %}
<img src="{{ asset(photo | imagine_filter('medium')) }}" />
{% endfor %}
图像未渲染,路径根本找不到错误。
任何提示?
答案 0 :(得分:0)
默认的nginx配置会将以jpg,gif等结尾的URL短路到文件系统而不是应用程序。你应该像这样改进你的nginx配置:
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ \.(png|jpeg|jpg|gif)$ {
if (-f $request_filename) {
expires 365d;
access_log off;
}
try_files $uri @rewriteapp;
}