{% set paragraph_classes = [
  'photo-gallery',
  reverse_layout ? 'photo-gallery--reverse' : 'photo-gallery--normal',
] %}
{% set attributes = attributes|default(create_attribute()) %}

{% if paragraph_field_caption %}
  {% set paragraph_tag = 'figure' %}
{% endif %}

{% extends "@ui-paragraph/paragraph.html.twig" %}

{% block paragraph_content %}
  {% for group in paragraph_field_erp_images|batch(4) %}
    <div class="photo-gallery__group">
      {% for image in group %}
        <div class="photo-gallery__image">
          {{ image }}
        </div>

        {# Only put an empty cell if there are 4 images. #}
        {% if loop.last and loop.length == 4 %}
          <div class="photo-gallery__empty-cell"></div>
        {% endif %}
      {% endfor %}
    </div>
  {% endfor %}

  {% if paragraph_field_caption %}
    <figcaption>{{ paragraph_field_caption }}</figcaption>
  {% endif %}
{% endblock %}
