Liipimaginebundle Twig图像链接缩略图 - Symfony 2

时间:2015-01-27 13:01:01

标签: php symfony twig liipimaginebundle

我有这个链接:

<img src="{{ asset('uploads/gallery/'~ i.imageName ~'' | imagine_filter('my_thumb')) }}" /> 

的routing.yml

_liip_imagine:
resource: "@LiipImagineBundle/Resources/config/routing.xml"

捆绑包的这个config.yml

liip_imagine:
resolvers:
   default:
      web_path: ~

filter_sets:
    cache: ~
    my_thumb:
        quality: 75
        filters:
            thumbnail: { size: [120, 90], mode: outbound }

但是symfony一直给我这个例外:

An exception has been thrown during the rendering of a template ("Parameter "path" for route "liip_imagine_filter" must match ".+" ("" given) to generate a corresponding URL.") in VdvTimesheetsBundle:Timesheets:show_image.html.twig at line 16.

有人知道这有什么问题吗?

谢谢!

1 个答案:

答案 0 :(得分:-1)

您可以在之前使用链接设置参数并使用

{% set img = 'uploads/gallery/'~ i.imageName   %}
<img src="{{ img| imagine_filter('my_thumb')) }}" />