[英]Symfony2: LiipImagineBundle - Exception: Unable to generate a URL for the named route “_imagine_image_upload_thumbnail” as such route does not exist
I am using LiipImagineBundle 我正在使用LiipImagineBundle
I have followed installing instruction as in the documentation 我已按照文档中的说明进行安装
in AppKernel.php 在AppKernel.php中
new Liip\ImagineBundle\LiipImagineBundle(),
and in routing.yml 并在routing.yml中
# app/config/routing.yml
_imagine:
resource: .
type: imagine
And in config.yml 并在config.yml中
#app/config/config.yml
liip_imagine:
filter_sets:
image_upload_thumbnail:
quality: 85
filters:
thumbnail: { size: [150, 150], mode: outbound }
and in my twig file 在我的树枝文件中
<img alt="{{ media.title|default('untitled') }}" src="{{ media.getWebPath | imagine_filter('image_upload_thumbnail') }}"/>
I get this error 我得到这个错误
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.")
What i have tried : 我试过的
media/cache
folder with the right permissions media/cache
文件夹 Try the following: 请尝试以下操作:
remove the spaces: 删除空格:
{{ media.webPath|imagine_filter('...') }}
... or invoke as a function: ...或作为函数调用:
{{ imagine_filter( media.webPath, 'filtername', false ) }}
Twig seems to invoke imagine_filter
as a twig function instead of as a twig filter. Twig似乎将
imagine_filter
作为imagine_filter
函数而不是imagine_filter
过滤器来调用。
You end up with media.webPath
not being passed as an argument. 您最终没有将
media.webPath
作为参数传递。
( tip: just use media.webPath
instead of media.getWebPath
- twig will automatically call the getter for you ) (提示:只需使用
media.webPath
而不是media.getWebPath
- media.getWebPath
会自动为您调用getter)
Actually the underlying function filter()
accepts the image-path as the first and the filter-name as it's second argument. 实际上, 底层函数
filter()
接受图像路径作为第一个参数,并接受filter-name作为第二个参数。
The third argument (boolean) determines wether to generate a relative or absolute url - defaults to false (relative). 第三个参数(布尔值)确定是否生成相对或绝对URL-默认为false(相对)。
Curently imagine uses the filter-name as a route-name and tries to generate a url ... which of course doesn't work :) 当前幻想使用过滤器名称作为路由名称并尝试生成url ...这当然不起作用:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.