{% set rows = post.get_field('blocks_text_images') %}

{% set orientation =  post.get_field('block_type') %}
{% set fullWidth =  post.get_field('full_width') %}
{% set alternateVertical =  post.get_field('alternate_vertical') %}
{% set isFullWidth = false %}
{% set styleBlock =  'container-image-text-inline' %}
{% set template =  "horizontal.twig" %}
{% set imageSize = 'lubie-large' %}
{% set imageFunction = 'getImagesSrc' %}
{% if fullWidth is iterable and fullWidth[0] == 2%}
    {% set isFullWidth = true %}
    {% set imageSize = 'lubie-large' %}
    {% set imageFunction = 'get_bg_image_src' %}
    {% set styleBlock = styleBlock ~ ' ' ~ styleBlock ~ '-' ~ fullWidth[0] %}
{% endif %}
{% if orientation == 2 %}
    {% set styleBlock =  'container-image-text-overlap' %}
    {% set template =  "vertical.twig" %}
    {% set animOverImg =  "" %}
    {% if alternateVertical is iterable and alternateVertical[0] is not empty%}
        {% set isAltStyle = true %}
        {% set styleBlock = styleBlock ~ ' ' ~ alternateVertical[0] %}
    {% endif %}
{% endif %}

<section class="{{ styleBlock }}">
        {% if not isFullWidth %}
        <div class="container-large content-inner">
        {% endif %}
        {% set nbText =  rows|length %}
        {% for row in rows %}
            {% set loopIndex = loop.index %}
            {% set img =  function(imageFunction, row['image'], imageSize) %}
            {% set caption =  row['img_caption'] %}
            {% set preTitle =  row['pre-title'] %}
            {% set hx = row['h_title'] %}
            {% set title =  row['section_title'] %}
            {% set text =  row['text'] %}
            {% set linkLabel = row['link_label'] %}
            {% set type = row['link_target'] %}

            {% set authorName =  row['author_name']%}
            {% set advisorSource =  row['advisor_source']%}
            {% if row['advisor_source'] is iterable and row['advisor_source'][0] is empty %}
                {% set advisorSource = "" %}
            {% endif %}
            {% if advisorSource is not empty or authorName is not empty  %}
                {% set template =  "horizontal.twig" %}
            {% endif %}

            {% set isFile = false %}
            {% if type == 2  %}
                {% set href = row['url_link'] %}
            {% elseif type == 3 %}
                {% set isFile =  true %}
                {% set href = row['file_link']['url'] %}
            {% else %}
                {% set href = row['internal_link'] %}
            {% endif %}
            {% set btnIcon =  'btn-arrow-right' %}

            {% embed template %}{% endembed %}

        {% endfor %}
    {% if not isFullWidth %}
    </div>
    {% endif %}
</section>
