Skip to content

Commit

Permalink
Merge pull request #788 from City-of-Helsinki/UHF-8938
Browse files Browse the repository at this point in the history
UHF-8938: Caption field for TPR-units
  • Loading branch information
teroelonen authored Oct 5, 2023
2 parents 00c6881 + 601fcb1 commit 34d158f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions hdbt.theme
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
}

/**
Expand Down
10 changes: 9 additions & 1 deletion templates/module/helfi_tpr/tpr-unit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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 #}
Expand Down

0 comments on commit 34d158f

Please sign in to comment.