我在我的 Symfony2 项目中使用LiipImagineBundle,一切都很好。我定义了一个缩略图过滤器:
<img src="{{ 'bundles/app/images/home/warning.jpg'|imagine_filter('thumb_home') }}" alt="Warning" />
而且效果很好,但是我的一些图像不需要任何过滤器,所以我尝试删除过滤器:
<img src="{{ 'bundles/app/images/home/warning.jpg'|imagine_filter('') }}" alt="Warning" />
<img src="{{ 'bundles/app/images/home/warning.jpg'|imagine_filter() }}" alt="Warning" />
**编辑以更正马尔科姆指出的示例
但它不起作用,所以我需要对这些图像使用Assetic :
{% image '@AppBundle/Resources/public/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example" />
{% endimage %}
我在捆绑包的文档中找不到任何允许我使用不带过滤器的捆绑包的选项。真的吗?当然,我可以在需要过滤器时使用 LiipImagineBundle 方式来包含图像,而在不需要过滤器时使用 Assetic 方式,但是在实现几乎相同的事情的两种不同方式之间切换非常烦人。