Additional parameters in `woocommerce_get_product_thumbnail` (#31605)
* Additional parameters in `woocommerce_get_product_thumbnail` * Protection against potential wrong types of parameters * Coding standards
This commit is contained in:
parent
a1523c39fb
commit
37794b2b7c
|
@ -1402,16 +1402,24 @@ if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
|
|||
* Get the product thumbnail, or the placeholder if not set.
|
||||
*
|
||||
* @param string $size (default: 'woocommerce_thumbnail').
|
||||
* @param int $deprecated1 Deprecated since WooCommerce 2.0 (default: 0).
|
||||
* @param int $deprecated2 Deprecated since WooCommerce 2.0 (default: 0).
|
||||
* @param array $attr Image attributes.
|
||||
* @param bool $placeholder True to return $placeholder if no image is found, or false to return an empty string.
|
||||
* @return string
|
||||
*/
|
||||
function woocommerce_get_product_thumbnail( $size = 'woocommerce_thumbnail', $deprecated1 = 0, $deprecated2 = 0 ) {
|
||||
function woocommerce_get_product_thumbnail( $size = 'woocommerce_thumbnail', $attr = array(), $placeholder = true ) {
|
||||
global $product;
|
||||
|
||||
|
||||
if ( ! is_array( $attr ) ) {
|
||||
$attr = array();
|
||||
}
|
||||
|
||||
if ( ! is_bool( $placeholder ) ) {
|
||||
$placeholder = true;
|
||||
}
|
||||
|
||||
$image_size = apply_filters( 'single_product_archive_thumbnail_size', $size );
|
||||
|
||||
return $product ? $product->get_image( $image_size ) : '';
|
||||
return $product ? $product->get_image( $image_size, $attr, $placeholder ) : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue