diff --git a/src/Service/UWService.php b/src/Service/UWService.php index f9e725c8a7fcd95672b334520bfe0d2c98a69434..62c123f3290bb8a9aa4cf0b4fbcd5d54d6cd4982 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -114,6 +114,8 @@ class UWService implements UWServiceInterface { $get_content = FALSE; $get_title = TRUE; + $featured_image = $this->uwGetFeaturedImageContentTypes(); + // Setup flags based on teaser content argument. if ($content == 'all') { $get_header = TRUE; @@ -126,7 +128,10 @@ class UWService implements UWServiceInterface { if ($view_mode == 'full') { $get_title = FALSE; - $get_image = TRUE; + + if (in_array($node->getType(), array_keys($featured_image))) { + $get_image = TRUE; + } } } else { @@ -222,7 +227,7 @@ class UWService implements UWServiceInterface { 'title' => $get_title ? TRUE : NULL, 'sub_title' => $get_header ? 'field_uw_ct_contact_title' : NULL, 'affiliation' => $get_header ? 'field_uw_ct_contact_affiliation' : NULL, - 'image' => $get_header ? 'field_uw_ct_contact_image' : NULL, + 'image' => $get_image ? 'field_uw_ct_contact_image' : NULL, 'content' => $get_content ? 'layout_builder__layout' : NULL, 'email' => $get_footer ? 'field_uw_ct_contact_email' : NULL, 'location' => $get_footer ? 'field_uw_ct_contact_location' : NULL, @@ -353,6 +358,17 @@ class UWService implements UWServiceInterface { return $node_data; } + /** + * {@inheritDoc} + */ + public function uwGetFeaturedImageContentTypes(): array { + return [ + 'uw_ct_blog' => 'field_uw_blog_listing_page_image', + 'uw_ct_event' => 'field_uw_event_listing_page_img', + 'uw_ct_news_item' => 'field_uw_news_listing_page_image', + ]; + } + /** * {@inheritDoc} */ diff --git a/src/Service/UWServiceInterface.php b/src/Service/UWServiceInterface.php index 60b58a64db705bc4eb84090c45dfe07fc424730c..576830ea4660d92a550b403b8693bf3bc89626fa 100644 --- a/src/Service/UWServiceInterface.php +++ b/src/Service/UWServiceInterface.php @@ -58,6 +58,14 @@ interface UWServiceInterface { */ public function uwGetNodeData(Node $node, string $view_mode, array $content_data): array; + /** + * Gets content types that have feature images. + * + * @return array + * Array of content types that has featured images. + */ + public function uwGetFeaturedImageContentTypes(): array; + /** * Gets dates from node. *