2014-03-02 24 views
1

我使用LiipImagineBundle的Symfony2:LiipImagineBundle - 異常:無法生成名爲路線「_imagine_image_upload_thumbnail」這樣路線的網址不存在

我按照安裝說明,如文檔中

在AppKernel .PHP

new Liip\ImagineBundle\LiipImagineBundle(), 

和在routing.yml中

# app/config/routing.yml 

_imagine: 
    resource: . 
    type:  imagine 

而且在config.yml

#app/config/config.yml 
liip_imagine: 
    filter_sets: 
     image_upload_thumbnail: 
      quality: 85 
      filters: 
       thumbnail: { size: [150, 150], mode: outbound } 

,並在我的樹枝文件

<img alt="{{ media.title|default('untitled') }}" src="{{ media.getWebPath | imagine_filter('image_upload_thumbnail') }}"/> 

我得到這個錯誤

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_imagine_image_upload_thumbnail" as such route does not exist.") 

我曾嘗試:

  • Cache clear
  • php app/console router:debug | grep的想象沒有發現
  • 路線這麼想的存在,並沒有登記
  • 驗證了我有media/cache文件夾正確的權限

回答

1

嘗試以下操作:

刪除空格:

{{ media.webPath|imagine_filter('...') }} 

...或作爲函數調用:

{{ imagine_filter(media.webPath, 'filtername', false) }} 

枝似乎調用imagine_filter作爲枝功能而不是作爲枝過濾器。

您最終以media.webPath未被作爲參數傳遞。

(提示:只要使用media.webPath代替media.getWebPath - 樹枝會自動調用的getter你)

其實underlying function filter()接受圖像路徑作爲第一和過濾器名稱作爲它的第二個參數。

第三個參數(布爾值)決定是否生成相對或絕對url - 默認爲false(相對)。

Curently想象使用過濾器名稱作爲路由名稱和嘗試生成網址...這當然行不通:)

+0

感謝@nifr的回答,但沒有奏效,問題是路由不存在,甚至沒有運行'php app/console router:debug | grep想象' –

+0

您需要按照說明將其添加到您的routing.yml中:'_imagine: resource:。 類型:想象' –

+0

我和@AhmedSamy有同樣的問題。 –