WC_API_Products::upload_image_from_url( string $image_url, string $upload_for = 'product_image' )
Upload image from URL.
Description Description
Parameters Parameters
- $image_url
-
(Required)
- $upload_for
-
(Optional)
Default value: 'product_image'
Return Return
(array)
Source Source
File: includes/legacy/api/v3/class-wc-api-products.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;
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |