diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 5df3c269910156bd27288d1bab02e140765e94b6..365aad3a5174969e2c0a370883ce4f4f89b90683 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -250,38 +250,42 @@ class UWService implements UWServiceInterface { /** * {@inheritDoc} */ - public function uwGetMediaFlags(Node $node): array { + public function uwGetMediaFlags(Node $node, string $view_mode = NULL): array { // Set the defaults for the flags to false. $media_flags['has_media'] = FALSE; $media_flags['show_header_in_media'] = FALSE; $media_flags['has_portrait'] = FALSE; - // If there is a type of media field, continue to look - // for media flags. - if ($node->hasField('field_uw_type_of_media')) { + // If we are not on a teaser, then set the media flags. + if ($view_mode !== 'teaser') { - // If there is a type of media set, then set has_media, - // and look for media in header. - if ($type_of_media = $node->field_uw_type_of_media->value) { + // If there is a type of media field, continue to look + // for media flags. + if ($node->hasField('field_uw_type_of_media')) { + + // If there is a type of media set, then set has_media, + // and look for media in header. + if ($type_of_media = $node->field_uw_type_of_media->value) { - // Set has_media flag. - $media_flags['has_media'] = TRUE; + // Set has_media flag. + $media_flags['has_media'] = TRUE; - // If the type of media is image, the header needs to - // go inside the media, so set the flag. - if ($type_of_media == 'image') { - $media_flags['show_header_in_media'] = TRUE; + // If the type of media is image, the header needs to + // go inside the media, so set the flag. + if ($type_of_media == 'image') { + $media_flags['show_header_in_media'] = TRUE; + } } - } - // Special case is contact, we need to look if there - // is a portrait image and if so set the has_media. - if ($node->getType() == 'uw_ct_contact') { + // Special case is contact, we need to look if there + // is a portrait image and if so set the has_media. + if ($node->getType() == 'uw_ct_contact') { - // If there is a portrait image, set the has_media. - if ($node->field_uw_ct_contact_image->getValue()) { - $media_flags['has_portrait'] = TRUE; + // If there is a portrait image, set the has_media. + if ($node->field_uw_ct_contact_image->getValue()) { + $media_flags['has_portrait'] = TRUE; + } } } } diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php index a9fe706c11029f92998c69c0c9ac81e1b88cd6a2..6c5049020a90ee1c258d36af8f775f14c784ff89 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -64,11 +64,13 @@ interface UWServiceInterface { * * @param \Drupal\node\Node $node * Node entity. + * @param string $view_mode + * The view mode of the node. * * @return array * Array of flags for media. */ - public function uwGetMediaFlags(Node $node): array; + public function uwGetMediaFlags(Node $node, string $view_mode = NULL): array; /** * Gets dates from node.