From e2f0126936ab4cc6d690c6d2294cfe8dbb25b1d4 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 12 Dec 2017 17:08:01 +0000 Subject: [PATCH] Filter passed images before processing. --- includes/api/class-wc-rest-products-controller.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index 8e35789c8b2..25b57b1a638 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -1046,7 +1046,9 @@ class WC_REST_Products_Controller extends WC_REST_Legacy_Products_Controller { * @return WC_Product */ protected function set_product_images( $product, $images ) { - if ( is_array( $images ) && ! empty( $images ) ) { + $images = is_array( $images ) ? array_filter( $images ) : array(); + + if ( ! empty( $images ) ) { $gallery = array(); foreach ( $images as $image ) {