templates/utils/image.position.html.twig line 1

Open in your IDE?
  1. {% if thumbnailString == '' %}
  2.   {% set thumbnailString = 'col-6' %}
  3. {% endif %}
  4. {% set markers = image.getMarker() %}
  5. {% set markerX = '' %}
  6. {% set markerY = '' %}
  7. {% set break = false %}
  8. {% for marker in markers %}
  9.   {% if not break %}
  10.     {% if marker.data == [] and marker.name == '' %}
  11.       {% set markerX = marker.left %}
  12.       {% set markerY = marker.top %}
  13.       {% set break = true %}
  14.     {% endif %}
  15.   {% endif %}
  16. {% endfor %}
  17. {# This is how the image postion is determined.
  18.     If one coordinate fits within an area it gets the corresponding class
  19.         x
  20.       y  +---left---+--center--+-- right--+
  21.     top | < 33.333 | < 66.666 |  < 100   |
  22.         |----------|----------|----------|
  23.   center | < 66.666 |          |          |
  24.         |----------|----------|----------|
  25.   bottom |  < 100   |          |          |
  26.         +----------+----------+----------+
  27.   #}
  28. {% if markerX > 0 and markerY > 0 %}
  29.   {% set imagePosition = image_marker_position_x_y(markerX, markerY) %}
  30. {% else %}
  31.   {% set imagePosition = 'center-center' %}
  32. {% endif %}
  33. <div class="image-position-{{imagePosition}}">
  34.   {{ image.thumbnail(thumbnailString).html | raw }}
  35.   {% if imageTitleShow %}
  36.     {% set image = image.getImage() %}
  37.     {% if imageTitleInput %}
  38.       <div class="c-image__title">
  39.         {{ imageTitleInput | raw }}
  40.       </div>
  41.     {% elseif image.getMetadata('title') %}
  42.       <div class="c-image__title">
  43.         {{ image.getMetadata('title') | raw }}
  44.       </div>
  45.     {% endif %}
  46.   {% endif %}
  47. </div>