You are here

insert-colorbox-image.html.twig in Insert 8.2

Template file for images inserted via the Insert module.

Available variables:

  • attributes: Additional attributes.
  • class: A set of classes assigned to this image (if any).
  • class_colorbox: A set of classes assigned to the link.
  • entity_type: The type of the entity inserted.
  • field_type: The field type the rendered template belongs to, i.e. "file" or "image".
  • gallery_id: The id of the colorbox gallery.
  • height: The height of the image (if known).
  • id: A unique id that is used in templates and button for synchronisation.
  • insert_settings: Insert widget settings.
  • item: The complete item being inserted.
  • style_name: The Image style being used.
  • url: The URL to the image being inserted visually; May be a styled image or the full size image.
  • url_link: URL of the image derivative, the inserted image shall link to.
  • url_original: The URL to the original (full size) image.
  • uuid: The file's UUID.
  • width: The width of the image (if known).

Available attachment keys for the data-insert-attach attribute:

  • alt: The text entered in the image field widget's ALT text box.
  • title: The text entered in the image field widget's title text box.
  • description: The text entered in the field's description text box (if the image is inserted using a generic file field).
  • filename: The file name.

See module documentation at https://www.drupal.org/docs/8/modules/insert on how to specify the data-insert-attach attribute.

File

modules/insert_colorbox/templates/insert-colorbox-image.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Template file for images inserted via the Insert module.
  5. *
  6. * Available variables:
  7. * - attributes: Additional attributes.
  8. * - class: A set of classes assigned to this image (if any).
  9. * - class_colorbox: A set of classes assigned to the link.
  10. * - entity_type: The type of the entity inserted.
  11. * - field_type: The field type the rendered template belongs to, i.e. "file" or
  12. * "image".
  13. * - gallery_id: The id of the colorbox gallery.
  14. * - height: The height of the image (if known).
  15. * - id: A unique id that is used in templates and button for synchronisation.
  16. * - insert_settings: Insert widget settings.
  17. * - item: The complete item being inserted.
  18. * - style_name: The Image style being used.
  19. * - url: The URL to the image being inserted visually; May be a styled image or
  20. * the full size image.
  21. * - url_link: URL of the image derivative, the inserted image shall link to.
  22. * - url_original: The URL to the original (full size) image.
  23. * - uuid: The file's UUID.
  24. * - width: The width of the image (if known).
  25. *
  26. * Available attachment keys for the data-insert-attach attribute:
  27. * - alt: The text entered in the image field widget's ALT text box.
  28. * - title: The text entered in the image field widget's title text box.
  29. * - description: The text entered in the field's description text box (if the
  30. * image is inserted using a generic file field).
  31. * - filename: The file name.
  32. * See module documentation at https://www.drupal.org/docs/8/modules/insert
  33. * on how to specify the data-insert-attach attribute.
  34. */
  35. #}
  36. {% spaceless %}
  37. {% set classes = [] %}
  38. {% if style_name != 'image' %}
  39. {% set classes = classes|merge(['image-' ~ style_name]) %}
  40. {% endif %}
  41. {% if class %}
  42. {% set classes = classes|merge([class]) %}
  43. {% endif %}
  44. <a href="{{ url_link }}" class="colorbox insert-colorbox" data-insert-type="{{ field_type }}"{% if gallery_id != '' %} data-colorbox-gallery="{{ gallery_id }}"{% endif %}>
  45. <img src="{{ url }}"{{ attributes }} {% if width and height %}width="{{ width }}" height="{{ height }}" {% endif %}{% if classes|length %} class="{{ classes|join(' ') }}"{% endif %} data-insert-type="{{ field_type }}" data-entity-type="{{ entity_type }}" data-entity-uuid="{{ uuid }}" data-insert-attach='{"id": "{{ id }}", "attributes": {"alt": ["alt", "description"], "title": ["title"]{% if insert_caption %}, "data-caption": ["title"]{% endif %}}}' />
  46. </a>
  47. {% endspaceless %}