Filter
restropress_rest_suppress_image_upload_error
On this page
Filters whether a failed image upload from a URL should be silently ignored.
Used in the ImageAttachment helper when uploading an image from a source URL fails with a WP_Error. Returning true makes the helper return quietly instead of throwing an exception.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$suppress | bool | Default false. |
$upload | WP_Error | The upload error. |
$object_id | int | ID of the object the image belongs to. |
$images | mixed | Passed as an undefined variable in the source, so it is null. |
Return value#
bool. True to ignore the error.
Example#
function my_suppress_image_upload_error( $suppress, $upload, $object_id, $images ) {
return true;
}
add_filter( 'restropress_rest_suppress_image_upload_error', 'my_suppress_image_upload_error', 10, 4 );
Notes#
This code is adapted from WooCommerce, calls wc_rest_upload_image_from_url() and throws WC_REST_Exception, and the ImageAttachment class is not used anywhere else in the plugin, so the hook is effectively unreachable.
Source#
Applied in:
includes/rest-api/Utilities/ImageAttachment.php(line 43), inImageAttachment::upload_image_from_src()
Was this page helpful?
