WordPress.org

Support

Support » Plugins and Hacks » [Plugin: JSON API] Help with (4.6. Attachment response object)

[Plugin: JSON API] Help with (4.6. Attachment response object)

  • generalChaos
    Member

    @generalchaos

    I am a big fan of the JSON API plugin, great job and thanks so much. I am learning how to work with json and jquery and am trying to limit the information I get back from a request. I have been able to use the include and custom field options successfully but amd falling a little short understanding 4.6. Attachment response object. Is there a way to limit the result to only provide thumb images? If so, can anyone provide an example of the syntax. I am not sure how to address these objects in the query string. Any help would be awesome. Let me know if I need to clarify anything.

    Regards,
    Fellow JSON API fan

    http://wordpress.org/extend/plugins/json-api/

Viewing 1 replies (of 1 total)
  • You can use the filter they provide to unset whatever sizes you don’t need

    add_filter('json_api_encode', 'my_encode_attachments');
    
    function my_encode_attachments($response) {
      if (isset($response['posts'])) {
        foreach ($response['posts'] as $post) {
    		foreach ($post->attachments as $attachment){
    			unset($attachment->images['full']);
    			unset($attachment->images['thumbnail']);
    		}
        }
      }
      return $response;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: JSON API] Help with (4.6. Attachment response object)’ is closed to new replies.