简体   繁体   English

Symfony2:LiipImagineBundle-异常:无法为命名路由“ _imagine_image_upload_thumbnail”生成URL,因为该路由不存在

[英]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 : 我试过的

  • Cache clear 清除缓存
  • php app/console router:debug | php app /控制台路由器:调试| grep imagine found none grep想像没有找到
  • Route dosen't exist and not registered 路线不存在且未注册
  • Validated that i have 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM