diff --git a/hdbt.theme b/hdbt.theme index a871d09b3..9751db709 100644 --- a/hdbt.theme +++ b/hdbt.theme @@ -1297,6 +1297,16 @@ function hdbt_preprocess_tpr_unit(&$variables): void { // Add cookie compliance JS to unit pages since they have maps. $variables['#attached']['library'][] = 'hdbt/embedded-content-cookie-compliance'; + + // Handle TPR unit picture caption preprocessing. + if ($entity->hasField('picture_url_override')) { + _hdbt_preprocess_image_caption( + $variables, + 'entity', + 'picture_url_override', + 'unit_picture_caption' + ); + } } /** diff --git a/templates/module/helfi_tpr/tpr-unit.html.twig b/templates/module/helfi_tpr/tpr-unit.html.twig index 2f74884f4..ba417500e 100644 --- a/templates/module/helfi_tpr/tpr-unit.html.twig +++ b/templates/module/helfi_tpr/tpr-unit.html.twig @@ -45,10 +45,18 @@ {% set main_image = content.picture_url %} {% endif %} + {# Main image caption #} + {% if unit_picture_caption|render %} + {% set main_image_caption = unit_picture_caption %} + {% else %} + {% set main_image_caption = '' %} + {% endif %} + {% if main_image %} {% include '@hdbt/misc/image-with-caption.twig' with { figure_class: 'main-image', - image: main_image + image: main_image, + image_caption: main_image_caption } %} {% endif %} {# End of Main image #}