From 3654b09d59411f804edd77528cfdb75114e1914d Mon Sep 17 00:00:00 2001 From: nickrouty Date: Mon, 30 Jan 2017 11:52:36 -0700 Subject: [PATCH] Add filter to thumbnail image We store an external image in post meta for our products. We weren't able to hook into the prior calls to perform what we were needing to accomplish due to the post ID / product ID not being available globally. Due to this, the easiest thing would be to be able to view what was about to be returned via the get_thumbnail function, along with the product ID. We then take the ID, check if a product image exists in our post meta, and if so, update the return value. --- includes/api/products.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/api/products.php b/includes/api/products.php index bddd85c1..75ea74df 100644 --- a/includes/api/products.php +++ b/includes/api/products.php @@ -290,7 +290,7 @@ private function get_thumbnail($id){ if( is_array($image) ) return $image[0]; - return wc_placeholder_img_src(); + return apply_filters( 'woocommerce_pos_placeholder_img_src', wc_placeholder_img_src(), $id ); } /** @@ -538,4 +538,4 @@ private function format_id( $id ){ return array( 'id' => (int) $id ); } -} \ No newline at end of file +}