Merge pull request #1202 from CodeRepublic/master
Modify WC_Product::get_image() for return
This commit is contained in:
commit
9b73be6eb1
|
@ -1089,16 +1089,22 @@ class WC_Product {
|
|||
/**
|
||||
* Gets the main product image
|
||||
*/
|
||||
function get_image( $size = 'shop_thumbnail' ) {
|
||||
function get_image( $size = 'shop_thumbnail', $echo = true ) {
|
||||
global $woocommerce;
|
||||
|
||||
if (has_post_thumbnail($this->id)) :
|
||||
echo get_the_post_thumbnail($this->id, $size);
|
||||
$output = '';
|
||||
if (has_post_thumbnail($this->id)) :
|
||||
$output = get_the_post_thumbnail($this->id, $size);
|
||||
elseif (($parent_id = wp_get_post_parent_id( $this->id )) && has_post_thumbnail($parent_id)) :
|
||||
echo get_the_post_thumbnail($parent_id, $size);
|
||||
$output = get_the_post_thumbnail($parent_id, $size);
|
||||
else :
|
||||
echo '<img src="'. woocommerce_placeholder_img_src() . '" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />';
|
||||
$output = '<img src="'. woocommerce_placeholder_img_src() . '" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />';
|
||||
endif;
|
||||
|
||||
if ( $echo ) {
|
||||
echo $output;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,7 +41,7 @@ global $woocommerce;
|
|||
<!-- The thumbnail -->
|
||||
<td class="product-thumbnail">
|
||||
<?php
|
||||
$thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key );
|
||||
$thumbnail = apply_filters( 'woocommerce_in_cart_product_thumbnail', $_product->get_image(null, false)/* default size, no output */, $values, $cart_item_key );
|
||||
printf('<a href="%s">%s</a>', esc_url( get_permalink( apply_filters('woocommerce_in_cart_product_id', $values['product_id'] ) ) ), $thumbnail );
|
||||
?>
|
||||
</td>
|
||||
|
|
Loading…
Reference in New Issue