[英]Symfony2: LiipImagineBundle - Exception: Unable to generate a URL for the named route “_imagine_image_upload_thumbnail” as such route does not exist
我正在使用LiipImagineBundle
我已按照文檔中的說明進行安裝
在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.")
我試過的
media/cache
文件夾 請嘗試以下操作:
刪除空格:
{{ media.webPath|imagine_filter('...') }}
...或作為函數調用:
{{ imagine_filter( media.webPath, 'filtername', false ) }}
Twig似乎將imagine_filter
作為imagine_filter
函數而不是imagine_filter
過濾器來調用。
您最終沒有將media.webPath
作為參數傳遞。
(提示:只需使用media.webPath
而不是media.getWebPath
- media.getWebPath
會自動為您調用getter)
實際上, 底層函數filter()
接受圖像路徑作為第一個參數,並接受filter-name作為第二個參數。
第三個參數(布爾值)確定是否生成相對或絕對URL-默認為false(相對)。
當前幻想使用過濾器名稱作為路由名稱並嘗試生成url ...這當然不起作用:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.