WordPress at a glance
function is not described

WC_API_Products::upload_image_from_url() protected WC 2.5.0

Upload image from URL.

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

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->upload_image_from_url( $image_url, $upload_for );
$image_url(string) (required)
-
$upload_for(string)
-

Changelog

Since 2.5.0 Introduced.

Code of WC_API_Products::upload_image_from_url() WC 5.0.0

<?php
protected function upload_image_from_url( $image_url, $upload_for = 'product_image' ) {
	$upload = wc_rest_upload_image_from_url( $image_url );
	if ( is_wp_error( $upload ) ) {
		throw new WC_API_Exception( 'woocommerce_api_' . $upload_for . '_upload_error', $upload->get_error_message(), 400 );
	}

	do_action( 'woocommerce_api_uploaded_image_from_url', $upload, $image_url, $upload_for );

	return $upload;
}