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

Path

WHAT ISGet details about WordPress’s “uploads” folder.
DONEReturn a MediaPath object containing information about the “uploads” folder.
ERRORReturn the WordPress system error message (see the WP Code Reference).
USED WP
METHODS
wp_upload_dir

_ = wpMedia.$Path$().$Done$(%doneCallback%).$Error$(%errorCallback%).$Run$();

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}}}
__
.GetMediaPath()|[MediaPath]
Return a MediaPath object(see the GetMediaPath() paragraph below).
__
.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.


MediaPath

The MediaPath class exposes properties with the details of the “uploads” folder (see the WordPress manual for details).

path|string
Base directory and sub directory or full path to upload directory.
__
url|string
Base url and sub directory or absolute URL to upload directory.
__
subdir|string
Sub directory if uploads use year/month folders option is on.
__
basedir|string
Path without subdir.
__
baseurl|string
URL path without subdir.
__
error|bool
TRUE in case of error.


GetMediaPath()

The GetMediaPath() method of the WPReply class returns a MediaPath object. This object contains information about the WordPress Media folder (“uploads” folder).

var myMedia = new UniWP.Media();

_ = myMedia.Path()
    .Done((WPReply reply) => 
    {
        if (reply.isOK) {

           var mediaFolder = reply.GetMediaFolder();

           Debug.Log("Media: " + m.path); 

        }
    })
    .Error((WPReply reply) => 
    {
        Debug.LogError(reply.error);
    })
    .Run()