{% 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 %}
PreviousNext
{% for image in all_images %}
{% thumbnail image.original "250x400" upscale=False as thumb %}
{% endthumbnail %}
{% endfor %}
{% else %}
{% with image=product.primary_image %}
{% thumbnail image.original "400x400" upscale=False as thumb %}
{% if not image.is_missing %}
{% else %}
{% endif %}
{% endthumbnail %}
{% endwith %}
{% endif %}
{% endwith %}