I’m trying to get a “thumbnail” image of a post in wordpress.
But I am not able to access nested JSON data
I created a jsFiddle link so you can see an example and may finish my html and AngularJS controller.
I might have to create a filter. But I can not, I’m stuck.
The goal is to get that thumbnail nested and place it as an image src
.
{
"ID": 45,
"title": "Lista Generada",
"status": "publish",
"type": "post",
"modified_gmt": "2015-03-11T21:04:47+00:00",
"featured_image":
{
"ID": 46,
"title": "eCommerce-checklist",
"status": "inherit",
"type": "attachment",
"is_image": true,
"attachment_meta":
{
"width": 1000,
"height": 857,
"file": "2015/03/eCommerce-checklist.jpg",
"sizes":
{
"medium":
{
"file": "eCommerce-checklist-300x257.jpg",
"width": 300,
"height": 257,
"mime-type": "image/jpeg",
"url": "http://localhost/wp-content/uploads/2015/03/eCommerce-checklist-300x257.jpg"
},
"post-thumbnail":
{
"file": "eCommerce-checklist-825x510.jpg",
"width": 825,
"height": 510,
"mime-type": "image/jpeg",
"url": "http://localhost/wp-content/uploads/2015/03/eCommerce-checklist-825x510.jpg"
}
},
}
},
}
First of all “post-thumbnail” is not valid and You should change – to _
Then you can access to your post_thumbnail.
post.featured_image.attachment_meta.sizes.post_thumbnail.url
Use
ng-src
, notsrc
. Also, your JSON is not valid.