Get image from ID, not post thumbnail

This commit is contained in:
Mike Jolley 2018-06-28 13:10:25 +01:00
parent 9bead7a702
commit 64b589f032
1 changed files with 5 additions and 4 deletions

View File

@ -1798,10 +1798,11 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* @return string * @return string
*/ */
public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) { public function get_image( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) {
if ( has_post_thumbnail( $this->get_id() ) ) { if ( $this->get_image_id() ) {
$image = get_the_post_thumbnail( $this->get_id(), $size, $attr ); $image = wp_get_attachment_image( $this->get_image_id(), $size );
} elseif ( ( $parent_id = wp_get_post_parent_id( $this->get_id() ) ) && has_post_thumbnail( $parent_id ) ) { // @phpcs:ignore Squiz.PHP.DisallowMultipleAssignments.Found } elseif ( $this->get_parent_id() ) {
$image = get_the_post_thumbnail( $parent_id, $size, $attr ); $parent_product = wc_get_product( $this->get_parent_id() );
$image = $parent_product->get_image();
} elseif ( $placeholder ) { } elseif ( $placeholder ) {
$image = wc_placeholder_img( $size ); $image = wc_placeholder_img( $size );
} else { } else {