WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: JSON API] set_thumbnail_value bug and fixed (2 posts)

  1. nyamsprod
    Member
    Posted 3 years ago #

    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/

  2. dphiffer
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags