WordPress at Your Fingertips
function is not described

WC_API_Products::upload_product_image() public WC 2.2

Upload image from URL

{} It's a method of the class: WC_API_Products{}

No Hooks.

Return

Array.

Usage

$WC_API_Products = new WC_API_Products();
$WC_API_Products->upload_product_image( $image_url );
$image_url(string) (required)
-

Changelog

Since 2.2 Introduced.

Code of WC_API_Products::upload_product_image() WC 5.7.1

public function upload_product_image( $image_url ) {
	$upload = wc_rest_upload_image_from_url( $image_url );
	if ( is_wp_error( $upload ) ) {
		throw new WC_API_Exception( 'woocommerce_api_product_image_upload_error', $upload->get_error_message(), 400 );
	}

	return $upload;
}