diff --git a/css/components/media-with-text.css b/css/components/media-with-text.css index 0c20e643..3a05516c 100644 --- a/css/components/media-with-text.css +++ b/css/components/media-with-text.css @@ -54,12 +54,8 @@ width: 100%; } -.media-with-text--media-left .media-with-text__body { - padding-inline-start: var(--spacing); -} - -.media-with-text--media-right .media-with-text__body { - padding-inline-end: var(--spacing); +.media-with-text .media-with-text__body { + padding-inline: var(--spacing); } .media-with-text--media-top .media-with-text__media { diff --git a/localgov_base.theme b/localgov_base.theme index ee8ea2bd..f6b16f2d 100644 --- a/localgov_base.theme +++ b/localgov_base.theme @@ -429,10 +429,40 @@ function localgov_base_preprocess_file_link(&$variables): void { $document_title = $variables['link']['#title']; if ($media) { - $media_name = $media->get('name')->getString(); - // If the media name is set and different to the - // $variables['link']['#title'], we will use that instead. - $document_title = ($media_name && $media_name !== $document_title) ? $media_name : $document_title; + // Assume some defaults for document media type. + $view_mode = 'default'; + $media_file_field_name = ($media->bundle() === 'document') ? 'field_media_document' : NULL; + + // Initialise description variables. + $use_description = FALSE; + $description = ''; + + if ($media_file_field_name) { + $entity_display_repository = \Drupal::service('entity_display.repository'); + $entity_display = $entity_display_repository->getViewDisplay($media->getEntityTypeId(), $media->bundle(), $view_mode); + $field_display = $entity_display->getComponent($media_file_field_name); + + if ($field_display && isset($field_display['settings']['use_description_as_link_text'])) { + $use_description = $field_display['settings']['use_description_as_link_text']; + } + } + + // Get the description from the file field if available. + if ($use_description && $file->_referringItem) { + $description = $file->_referringItem->description ?? ''; + } + + // Use description as link text if enabled and description exists. + if ($use_description && !empty($description)) { + $document_title = $description; + } + else { + // Otherwise, see about using the media name. + $media_name = $media->get('name')->getString(); + // If the media name is set and different to the + // $variables['link']['#title'], we will use that instead. + $document_title = ($media_name && $media_name !== $document_title) ? $media_name : $document_title; + } } $variables['link']['#title'] = [ diff --git a/templates/content/node--localgov-blog-channel--full.html.twig b/templates/content/node--localgov-blog-channel--full.html.twig index 4dd9beef..2828de10 100644 --- a/templates/content/node--localgov-blog-channel--full.html.twig +++ b/templates/content/node--localgov-blog-channel--full.html.twig @@ -118,11 +118,14 @@
{{ content|without('body', 'localgov_blog_channel_featured') }}
- + + {% if node.body.value %} + + {% endif %} diff --git a/templates/field/field--paragraph--localgov-paragraphs--localgov-box-links-listing.html.twig b/templates/field/field--paragraph--localgov-paragraphs--localgov-box-links-listing.html.twig index 3dfe6979..f50d5de7 100644 --- a/templates/field/field--paragraph--localgov-paragraphs--localgov-box-links-listing.html.twig +++ b/templates/field/field--paragraph--localgov-paragraphs--localgov-box-links-listing.html.twig @@ -42,11 +42,11 @@ {% set classes = [ 'box-links-listing__list-item', - ] + ] %} {% for item in items %} - {# - We are checking the parent here, and then using whatever layout style is chosen + {# + We are checking the parent here, and then using whatever layout style is chosen to set the width of the items. #} {% set parent = item.content['#paragraph']._referringItem.parent.parent.entity %} @@ -54,6 +54,10 @@ {% if theme == 'grid' %} {% set row_size = 'lgd-row__one-half' %} + {% elseif theme == 'grid-3' %} + {% set row_size = 'lgd-row__one-third' %} + {% elseif theme == 'grid-4' %} + {% set row_size = 'lgd-row__one-quarter' %} {% else %} {% set row_size = 'lgd-row__full' %} {% endif %}