1. Home
  2. Docs
  3. UniWP 1.5
  4. Media class
  5. Delete

Delete

WHAT ISDelete the given media IDs.
DONECalled on deletion completed.
ERRORCalled on a system error.
USED WP METHODSwp_delete_attachment

_ = wpMedia.$Delete$(%mediaIDs, %^forceDelete^).$Done$(%doneCallback%) .$Error$(%errorCallback%) .$Run$();

mediaIDs|array<int>
The array of the IDs of the media to delete.
__
forceDelete|(bool)
Default: false
By default, deleted Media will be stored in WordPress’s trash. If set to true, the Media will be permanently deleted.
__
doneCallback|function
The function to call when the operation will be completed.
Note: the use of the Done() method is mandatory.
__
errorCallback|(function)
The function to call in case of error.
Note: the use of the Error() method is optional and can be omitted.

{{{#912c9a|WPReply|Data-type|Property or method description}}}
__
.isOK|bool
true if everything is ok, false in case of error.
__
.isError|bool
true in case of error, false if everything is ok.
__
.error|string
The error message from the Server. It can be a string generated by WordPress through its get_error_message method (see the WP manual).
__
errorType|HttpRequest.Error Enum
The kind of error:
NONE = no error.
HTTP_ERROR = communication error.
SYSTEM_ERROR = UniWP error.
WORDPRESS_ERROR = error message from WordPress REST APIs.

var myMedia = new UniWP.Media();

_ = myMedia.Delete(new int[] {1, 10, 12, 24}, true)
    .Done((WPReply reply) => 
    {
        if (reply.isOK) Debug.Log("Media permanently deleted!");
    })
    .Error((WPReply reply) => 
    {
        Debug.LogError(reply.error);
    })
    .Run()