2015-10-25 41 views
1

我只是試圖讓LiipImagineBundle工作。Symfony2 LiipImagineBundle不能在Nginx上工作

#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 %} 

圖像不渲染,路徑根本就沒有發現錯誤。

任何提示?

http://i.stack.imgur.com/rVbwv.png

回答

0

默認nginx的配置將短路網址JPG,GIF等的文件系統,而不是到應用程序結束。你應該像這樣改進你的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; 
}