{% load thumbnail %} {% with product.images.all as all_images %} {# use length rather then count as the images get queried anyways #} {% if all_images|length > 1 %} {% else %} {% with image=product.primary_image %} {% thumbnail image.original "400x400" upscale=False as thumb %} {% if not image.is_missing %} image02 {% else %} image02 {% endif %} {% endthumbnail %} {% endwith %} {% endif %} {% endwith %}