Support » Plugin: JSON API » How to get list of media?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I found an example of getting media attachments with the controller on this page,

    I updated it to add the attachments as a property on the response object (IE, $output vs $output[‘attachments’]):

    Controller name: Attachments
    Controller description: Basic introspection methods for fetching attachments
    class JSON_API_Attachments_Controller{
        public function get_attachments(){
            global $json_api;
            if($json_api->query->parent !== "null")
                $parent = (integer) $json_api->query->parent;
                $parent = null;    
    	    $output = array();
    	    $output['attachments'] = $json_api->introspector->get_attachments($parent);
            return $output;

    Thanks to lego123. I’ll post updates to this thread as I make them.

    I was finally able to upload an attachment. Basically, after I was able to successfully update a post I added a new file form field and named it attachment and when I submit the form it uploads and updates the post at the same time. I don’t know how to add media without a post yet but this is fine for now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get list of media?’ is closed to new replies.