呼叫图片已弃用 [英] Calling image is deprecated
本文介绍了呼叫图片已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在日志中注意到了这一点(访问 www.sk8whls.com 的主页时):
I just noticed this in my logs (when visiting my homepage on www.sk8whls.com):
从模板"teasers/wheels.twig"中调用模板"macros/html.twig"上的"image"从1.28版开始已弃用,2.0版不再支持.
Calling "image" on template "macros/html.twig" from template "teasers/wheels.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
像这样的图像被称为(在预告片/wheels.twig中):
An image is called like this (in teasers/wheels.twig):
{{ html.image( image, 'thumbnail', fallback ) }}
我的宏如下:
{% macro image(image, size, fallback, alt, title, class ) %}
{% set image = image %}
{% set size = size|default('') %}
{% set fallback = fallback|default(0) %}
{% if image and image.src %}
<img src="{{ image.src(size) }}" alt="{% if alt %}{{ alt }}{% else %}{{ image.alt }}{% endif %}" title="{{ title }}" class="{{ class }}" />
{% elseif fallback %}
<img src="{{ fallback }}" alt="fallback" title="" />
{% endif %}
{% endmacro %}
我不确定为什么不赞成使用它,以及当v2.0支持消失时如何使它继续工作.
I'm not sure why it's deprecated and how I can keep it working when the support drops with v2.0.
推荐答案
查看全文