0

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"
                    }
                },
            }
        },
    }
1
  • That JSON is not valid, for future reference use a 3rd party to validate, such as : jsonlint.com Commented Mar 12, 2015 at 0:05

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

Comments

0

Use ng-src, not src. Also, your JSON is not valid.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.