diff --git a/lib/Newsletter/Editor/PostTransformer.php b/lib/Newsletter/Editor/PostTransformer.php index 562b813dee..087e58c8b5 100644 --- a/lib/Newsletter/Editor/PostTransformer.php +++ b/lib/Newsletter/Editor/PostTransformer.php @@ -47,7 +47,14 @@ class PostTransformer { $featured_image = $this->getFeaturedImage($post); $featured_image_position = $this->args['featuredImagePosition']; - if ($featured_image && $featured_image_position === 'belowTitle' && $this->args['displayType'] === 'excerpt') { + if ( + $featured_image + && $featured_image_position === 'belowTitle' + && ( + $this->args['displayType'] === 'excerpt' + || $this->isProduct($post) + ) + ) { array_unshift($content, $title, $featured_image); return $content; } @@ -73,7 +80,14 @@ class PostTransformer { $featured_image_position = $this->args['featuredImagePosition']; - if (!$featured_image || $featured_image_position === 'none' || $this->args['displayType'] !== 'excerpt') { + if ( + !$featured_image + || $featured_image_position === 'none' + || ( + $this->args['displayType'] !== 'excerpt' + && !$this->isProduct($post) + ) + ) { array_unshift($content, $title); return array( @@ -295,6 +309,10 @@ class PostTransformer { ); } + private function isProduct($post) { + return $post->post_type === 'product'; + } + /** * Replaces double quote character with a unicode * alternative to avoid problems when inlining CSS. diff --git a/tests/integration/Newsletter/Editor/PostContentTransformerTest.php b/tests/integration/Newsletter/Editor/PostContentTransformerTest.php index 0b9455ac84..a465c0d62f 100644 --- a/tests/integration/Newsletter/Editor/PostContentTransformerTest.php +++ b/tests/integration/Newsletter/Editor/PostContentTransformerTest.php @@ -274,6 +274,7 @@ class PostContentTransformerTest extends \MailPoetTest { Mock::double($transformer, array('getContent' => $content)); Mock::double($transformer, array('getFeaturedImage' => $image)); Mock::double($transformer, array('getTitle' => $title)); + Mock::double($transformer, array('isProduct' => false)); return $transformer; }