Merge pull request #11895 from tlovett1/api-silent-images-fail

(API) Add filter to continue uploading images if one fails
This commit is contained in:
Mike Jolley 2016-09-12 14:53:58 +01:00 committed by GitHub
commit 1037f9b8c4
1 changed files with 5 additions and 1 deletions

View File

@ -755,7 +755,11 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller {
$upload = wc_rest_upload_image_from_url( esc_url_raw( $image['src'] ) );
if ( is_wp_error( $upload ) ) {
throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 );
if ( ! apply_filters( 'woocommerce_rest_suppress_image_upload_error', false, $upload, $product_id, $images ) ) {
throw new WC_REST_Exception( 'woocommerce_product_image_upload_error', $upload->get_error_message(), 400 );
} else {
continue;
}
}
$attachment_id = wc_rest_set_uploaded_image_as_attachment( $upload, $product_id );