diff --git a/src/Service/UwNodeContent.php b/src/Service/UwNodeContent.php index b707bcc3542a7307f5c43a849ffe04cdeee4310d..8a2b21a27c03bddf267a238907ce2e4f05a02447 100644 --- a/src/Service/UwNodeContent.php +++ b/src/Service/UwNodeContent.php @@ -74,7 +74,7 @@ class UwNodeContent { break; case 'uw_ct_contact': - $content_data = $this->getContactContent($node_flags); + $content_data = $this->getContactContent($node_flags, $view_mode); break; case 'uw_ct_profile': @@ -467,11 +467,13 @@ class UwNodeContent { * * @param array $node_flags * The flags for the node. + * @param string $view_mode + * The view mode of the node. * * @return array * Array of content to get from the node. */ - public function getContactContent(array $node_flags): array { + public function getContactContent(array $node_flags, string $view_mode): array { // Get the content data. $content_data = $this->setupContentData($node_flags); @@ -481,8 +483,19 @@ class UwNodeContent { $content_data['header']['position'] = $this->addToContentData('plain_text', 'field_uw_ct_contact_title'); } + // If there is an image, we have to decide on which to get based + // on the view mode. if ($node_flags['get_image']) { - $content_data['image'] = $this->addToContentData('image', 'field_uw_ct_contact_image'); + + // If it is a teaser use the listing image, if not use the portrait image. + if ($view_mode == 'teaser') { + $content_data['image'] = $this->addToContentData('image', 'field_uw_contact_listing_image'); + } + else { + $content_data['image'] = $this->addToContentData('image', 'field_uw_ct_contact_image'); + } + + // Add the extra options for portrait image style. $content_data['image']['extra_options'] = [ 'type' => 'portrait', 'crop' => 'portrait',