Title: [Plugin: JSON API] set_thumbnail_value bug and fixed
Last modified: August 19, 2016

---

# [Plugin: JSON API] set_thumbnail_value bug and fixed

 *  Resolved [nyamsprod](https://wordpress.org/support/users/nyamsprod/)
 * (@nyamsprod)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-json-api-set_thumbnail_value-bug-and-fixed/)
 * I had to hack the code because the function could not populate the thumbnail 
   post property if the image was present in my media files BUT was not attached
   to the current post
 *     ```
       if (function_exists('get_post_thumbnail_id')) {
               $img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
               $this->thumbnail = $img[0];
           } else {
               $attachments = $json_api->introspector->get_attachments($this->id);
               foreach ($attachments as $attachment) {
                   if ($attachment->id == $values[0]) {
                       $image = $attachment->images['thumbnail'];
                       $this->thumbnail = $image->url;
                       break;
                   }
               }
           }
       ```
   
 * Hope it may help other people
 * [http://wordpress.org/extend/plugins/json-api/](http://wordpress.org/extend/plugins/json-api/)

Viewing 1 replies (of 1 total)

 *  [dphiffer](https://wordpress.org/support/users/dphiffer/)
 * (@dphiffer)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-json-api-set_thumbnail_value-bug-and-fixed/#post-1524106)
 * Thanks for the bug report. I included a modified version of this in the 1.0 release.
   Let me know if that fixes it for you.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: JSON API] set_thumbnail_value bug and fixed’ is closed to new
replies.

 * 1 reply
 * 2 participants
 * Last reply from: [dphiffer](https://wordpress.org/support/users/dphiffer/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/plugin-json-api-set_thumbnail_value-bug-and-fixed/#post-1524106)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
