• Resolved vivekdhar

    (@vivekdhar)


    Maybe somebody has solved this. After retrieving posts, how do you tell which of the attached images is the featured image?
    The featured image just shows up like a regular attachment, something like this:

    "attachments"=>
    [{"id"=>114,
      "url"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage.jpg",
      "slug"=>"media-6bgimage",
      "title"=>"media-6bgImage",
      "description"=>"",
      "caption"=>"",
      "parent"=>59,
      "mime_type"=>"image/jpeg",
      "images"=> {
        "full"=>{"url"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage.jpg", "width"=>1600, "height"=>1000},
        "thumbnail"=>{"url"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage-150x150.jpg", "width"=>150, "height"=>150},
        "medium"=>{"url"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage-300x188.jpg", "width"=>300, "height"=>188},
        "post-thumbnail"=>{"url"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage-825x510.jpg", "width"=>825, "height"=>510}
        }
      }
    ]

    https://ww.wp.xz.cn/plugins/json-api/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Chris Huff

    (@brochris)

    I don’t think you can tell by looking at the data from the images. I think you need to look at data from the posts themselves. Look for the value of the “_thumbnail_id” key, and if there’s a featured image attached, this should give you the ID of the image.

    Thread Starter vivekdhar

    (@vivekdhar)

    Oh man – I completely missed this. This *is* part of the post.
    "thumbnail"=>"http://test.com/wp-content/uploads/2015/04/media-6bgImage-825x510.jpg"

    Thanks, Chris!

    Thread Starter vivekdhar

    (@vivekdhar)

    Should have closed this.

    rafaelbuiu

    (@rafaelbuiu)

    I don’t get why my thumbnail variable is coming blank.

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

The topic ‘identify featured image from attachment array’ is closed to new replies.