{% set gallery_has_images = gallery_images is defined and gallery_images and (gallery_images|length > 0) %} {% if gallery_has_images %} {% for img in gallery_images %} {% endfor %} {% endif %}