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:
commit
1037f9b8c4
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue