core/modules/system/templates/image.html.twig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/modules/system/templates/image.html.twig b/core/modules/system/templates/image.html.twig index 2113b89..8c1e447 100644 --- a/core/modules/system/templates/image.html.twig +++ b/core/modules/system/templates/image.html.twig @@ -30,14 +30,15 @@ * @ingroup themeable */ #} -{% if uri is defined %} +{% spaceless %} +{% if uri is not empty %} {% set attributes = attributes.setAttribute('src', file_url(uri)) %} {% endif %} {# Generate a srcset attribute conforming to the spec at http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset #} -{% if srcset is defined %} +{% if srcset is not empty %} {% set srcset_attribute = [] %} {% for source in srcset %} {# URI is mandatory. #} @@ -57,8 +58,9 @@ already specifically defined. #} {% for attribute_name in ['width', 'height', 'alt', 'title', 'sizes'] %} - {% if _context[attribute_name] is defined and attributes[attribute_name] is not defined %} + {% if _context[attribute_name] is defined and attributes[attribute_name] is not empty %} {% set attributes = attributes.setAttribute(attribute_name, _context[attribute_name]) %} {% endif %} {% endfor %} +{% endspaceless %}