Wordpress JSON API working with images

Hi folks i’m just getting started with Ionic 2 and WP-JSON, i’ve managed to get everything i need into the API and have successfully pulled it in to my basic Ionic App and have managed to get most things displayed.

I’m just having a little bit of difficulty working with images. I’ll attach a link to my JSON so you can see but the feed actually contains a link to a list of all the images and i’m really not sure how to work with it …

I’d be grateful for any direction … Thanks !

http://competa.life/wp-json/wp/v2/listing

Ah that’s because featured media refers to a media object that’s exposed through wp-json/v2/media?id=featured_media_id . So you should do a GET on that endpoint for that particular media id, or already expose the image_url in the response you’re getting from /listing.

GET http://competa.life/wp-json/wp/v2/media?id=136 that wil probably give you the image sources for that media_id.

I appreciate your response, but as a total newbie i really don’t know how to proceed further, are you aware of any examples of how to get the actual image URL ? I have looked but really can’t see anything, i could be looking for the wrong thing. I did find a WP Plugin called Better REST API Featured Images, but this is only going to make life easier for the Featured Image, so i’m going to run into the same issue with attached galleries, so it would probably be a better idea to learn how to do it properly, if you could point me in the direction of an example i would be greatly appreciative, if such a thing exists.

Kind regards !

How was the /listings endpoint created? It seems to me that’s a custom endpoint, so I guessed there was some custom wordpress plugin code involved into making it available. Where does that endpoint come from?

1 Like

Hi there, yes it is a custom post type created by a commercial Wordpress Theme … The only thing i have done is make it available using WP REST API Controller.

You can do what he said, but I’m guessing you’ll also need a repeat section for each post.

You can install the Better Images plugin for WP-API so this is immediately accessible to you.

Thanks for that … Yes that Plugin work really well for Featured Images but it doesn’t address attached gallery images, which appear in the same default manner as Featured Images, pre-plugin.

Any suggestions would be greatly appreciated.

Thanks again