From 64b589f0325a729a1914942801f4b2cae929e013 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 28 Jun 2018 13:10:25 +0100 Subject: [PATCH] Get image from ID, not post thumbnail --- includes/abstracts/abstract-wc-product.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 714fa95d1e5..1bc55db0eb3 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1798,10 +1798,11 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @return string */ public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) { - if ( has_post_thumbnail( $this->get_id() ) ) { - $image = get_the_post_thumbnail( $this->get_id(), $size, $attr ); - } elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found - $image = get_the_post_thumbnail( $parent_id, $size, $attr ); + if ( $this->get_image_id() ) { + $image = wp_get_attachment_image( $this->get_image_id(), $size ); + } elseif ( $this->get_parent_id() ) { + $parent_product = wc_get_product( $this->get_parent_id() ); + $image = $parent_product->get_image(); } elseif ( $placeholder ) { $image = wc_placeholder_img( $size ); } else {