templates/_snippets/image.html.twig line 1

Open in your IDE?
  1. {% set mediaObject = image.image is not null ? image.image : null %}
  2. {% set imageUrl = image.isInternal == false and mediaObject is not null ? image.external_image : (mediaObject is not null ? sulu_get_media_url(mediaObject, 'inline') : image.external_image) %}
  3. {% set alt = image.alt|default('') %}
  4. {% set width = image.width|default(null) %}
  5. {% set widthUnit = image.widthUnit|default('%') %}
  6. {% set height = image.height|default(null) %}
  7. {% set heightUnit = image.heightUnit|default('%') %}
  8. {% set objectFit = image.objectFit|default('fill') %}
  9. {% set bordersRadius = image.bordersRadius|default(null) %}
  10. {% set bordersRadiusUnit = image.bordersRadiusUnit|default('px') %}
  11. {% set borderImageCheckbox = image.borderImageCheckbox|default(false) %}
  12. {% set boxShadowImageCheckbox = image.boxShadowImageCheckbox|default(false) %}
  13. {% set borderSizeImage = image.borderSizeImage|default(null) %}
  14. {% set borderSizeImageUnit = image.borderSizeImageUnit|default('px') %}
  15. {% set boxShadowPosXImage = image.boxShadowPosXImage|default(null) %}
  16. {% set boxShadowPosYImage = image.boxShadowPosYImage|default(null) %}
  17. {% set boxShadowSpreadImage = image.boxShadowSpreadImage|default(null) %}
  18. {% set boxShadowUnitImage = image.boxShadowUnitImage|default('px') %}
  19. {% set legend = image.legend|default('') %}
  20. {% set legendPosition = image.legendPosition|default('center') %}
  21. {% set clipPath = image.clipPath|default(null) %}
  22. {% set hasBorder = not borderImageCheckbox and borderSizeImage is not null %}
  23. {% set hasShadow = boxShadowImageCheckbox and (boxShadowPosXImage is not null or boxShadowPosYImage is not null or boxShadowSpreadImage is not null) %}
  24. {% set borderColor = image.borderColor %}
  25. <figure style="
  26. {% if width is not null %} width:{{ width }}{{ widthUnit }};{% endif %}
  27. {% if height is not null %} height:{{ height }}{{ heightUnit }}{% endif %}
  28. position: relative;
  29. ">
  30. <img
  31. class="img-fluid w-100"
  32. src="{{ imageUrl }}"
  33. alt="{{ alt }}"
  34. style="
  35. object-fit: {{ objectFit }};
  36. {% if bordersRadius is not null %}border-radius: {{ bordersRadius }}{{ bordersRadiusUnit }};{% endif %}
  37. {% if hasBorder %}
  38. border: {{ borderSizeImage }}{{ borderSizeImageUnit }} solid {{ borderColor}};
  39. {% endif %}
  40. {% if hasShadow %}
  41. box-shadow:
  42. {% if boxShadowPosXImage is not null %}{{ boxShadowPosXImage }}{{ boxShadowUnitImage }}{% else %}0px{% endif %}
  43. {% if boxShadowPosYImage is not null %}{{ boxShadowPosYImage }}{{ boxShadowUnitImage }}{% else %}0px{% endif %}
  44. {% if boxShadowSpreadImage is not null %}{{ boxShadowSpreadImage }}{{ boxShadowUnitImage }}{% else %}0px{% endif %}
  45. {% if borderColor is not null %} {{ borderColor }}{% else %} rgba(0,0,0,.5){% endif %};
  46. {% endif %}
  47. {% if clipPath and clipPath is not empty %}{{ clipPath }};{% endif %}
  48. "
  49. />
  50. {% if legend %}
  51. <figcaption class="figure-caption text-{{ legendPosition }} mt-2">
  52. {{ legend }}
  53. </figcaption>
  54. {% endif %}
  55. </figure>