Title: Thumbnails missing from JSON response
Last modified: September 1, 2016

---

# Thumbnails missing from JSON response

 *  [imnofox](https://wordpress.org/support/users/imnofox/)
 * (@imnofox)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/)
 * When requesting any posts, the thumbnail data is entirely missing.
 * In each post, the thumbnail and thumbnail items are empty.
 *     ```
       "thumbnail": null,
       "thumbnail_size": "thumbnail",
       "thumbnail_images": []
       ```
   
 * Is there a solution or workaround to get the featured image in my JSON output?
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [no.dots](https://wordpress.org/support/users/nodots-1/)
 * (@nodots-1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/#post-7651028)
 * Same problem here since a few days..
 *  [armetiz](https://wordpress.org/support/users/armetiz/)
 * (@armetiz)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/#post-8149394)
 * Hi there;
 * I have the same problem here.
 * Installed plugins :
    – advanced-custom-fields – simple-local-avatars – remove-
   category-url – json-api – categories-images
 * Any clue ?
 *  [csmith8646](https://wordpress.org/support/users/csmith8646/)
 * (@csmith8646)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/#post-8536059)
 * you ever find a solution? Recently installed Offload S3 Lite to move my images
   to S3, and that appears to be blowing out thumbnail info on this plugin. Disabling
   Offload and it works great.
 *  [robobobo100](https://wordpress.org/support/users/robobobo100/)
 * (@robobobo100)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/#post-8944537)
 * I’ve had the same problem and figured it out now.
 * The issue is that the JSON API plugin checks to see if a thumbnail file exists
   locally before it adds it to the JSON response. If it doesn’t exist it just omits
   it.
 * The problem is locating in json-api/models/attachment.php in the `query_images`
   function at line 48.
 * You’ll need to change this
 *     ```
        function query_images() {
           $sizes = array('thumbnail', 'medium', 'large', 'full');
           if (function_exists('get_intermediate_image_sizes')) {
             $sizes = array_merge(array('full'), get_intermediate_image_sizes());
           }
           $this->images = array();
           $home = get_bloginfo('url');
           foreach ($sizes as $size) {
             list($url, $width, $height) = wp_get_attachment_image_src($this->id, $size);
             $filename = ABSPATH . substr($url, strlen($home) + 1);
             if (file_exists($filename)) {
               list($measured_width, $measured_height) = getimagesize($filename);
               if ($measured_width == $width &&
                   $measured_height == $height) {
                 $this->images[$size] = (object) array(
                   'url' => $url,
                   'width' => $width,
                   'height' => $height
                 );
               }
             }
           }
         }
       ```
   
 * To this
 *     ```
        function query_images() {
           $sizes = array('thumbnail', 'medium', 'large', 'full');
           if (function_exists('get_intermediate_image_sizes')) {
             $sizes = array_merge(array('full'), get_intermediate_image_sizes());
           }
           $this->images = array();
           $home = get_bloginfo('url');
           foreach ($sizes as $size) {
             list($url, $width, $height) = wp_get_attachment_image_src($this->id, $size);
             $this->images[$size] = (object) array(
                   'url' => $url,
                   'width' => $width,
                   'height' => $height
                 );
           }
         }
       ```
   
 * And that will force the JSON api to return the S3 url and not bother checking
   if it exists locally

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Thumbnails missing from JSON response’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

## Tags

 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)
 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)

 * 4 replies
 * 5 participants
 * Last reply from: [robobobo100](https://wordpress.org/support/users/robobobo100/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/thumbnails-missing-from-json-response/#post-8944537)
 * Status: not resolved