Merge pull request #1202 from CodeRepublic/master

Modify WC_Product::get_image() for return
This commit is contained in:
Mike Jolley 2012-06-29 09:48:08 -07:00
commit 9b73be6eb1
2 changed files with 12 additions and 6 deletions

View File

@ -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;
}
/**

View File

@ -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>