Both images are featured images on different posts, inserted the exact same way.
How can one be accessible and the other not? Any reason for that? Any help?
Were they originally uploaded to unpublished posts, by chance? We don’t currently have a permissions model for permitting querying a featured image when it’s assigned to a private post.
No, the post is published and public.
http://interelgroup.com/blog/a-good-activist-is-always-a-bad-lobbyist/
Media ID 1134 is the thumbnail for this post.
Media ID 1134 is the thumbnail for this post.
Can you inspect the post_parent value for the 1134 row in the database, and make sure that post_parent is a public post?
Hmm…
The post parent (1122) is from a custom post type (published and public, but not of type “post”).
I assume that is the problem. What’s the safest way to solve it? Just change the parent id on the database directly?
Thanks!
I assume that is the problem. What’s the safest way to solve it? Just change the parent id on the database directly?
To solve your immediate problem now, yes. This type of problem is something we’ll need to address in the future though.
OK, thanks.
Actually I am using another plugin to get the featured images (JSON API by Dan Phiffer). I would prefer just to use yours.
Can’t you include the featured image URLs (all sizes) on the post response?
Like on this one: http://interelgroup.com/api/get_post/?post_id=4683
By the way, this one only works with JSONP, not regular JSON.
Basically I am getting the post ID with your api, and then use it to call the other api, like this:
$.getJSON('http://interelgroup.com/wp-json/wp/v2/posts/?filter[category_name]=belgium', {format: "json"}, function(data) {
for(var i=0; i<3; i++) {
$('<article data-index="'+i+'" class="be-post"></article>').appendTo("#belgium-posts");
}
$.each(data, function(key, value) {
if(key < 3) {
$('#belgium-posts article[data-index="'+key+'"]').html('<div class="row"><div class="col-xs-3"><img class="img-responsive"></div><div class="col-xs-9"><h4><a href="/blog/?id='+value["id"]+'">'+value["title"]["rendered"]+'</a></h4><main>'+value["acf"]["summary"]+'</main><a class="read-more" href="/blog/?id='+value["id"]+'">Read more...</a></div</div>');
$.getJSON('http://interelgroup.com/api/get_post/?post_id='+value["id"]+'&callback=?', {format: "jsonp"}, function(data) {
$('#belgium-posts article[data-index="'+key+'"]').find("img").attr("src", data.post.thumbnail_images.full.url);
});
}
});
});
Thanks.
Can’t you include the featured image URLs (all sizes) on the post response?
If you include the ?_embed param in your request, then linked resources will be fully embedded in the response.
Here’s where you can learn more about linked resources: http://v2.wp-api.org/extending/linking/
OK, great! 🙂
Let me know when you fix the permissions things.
Thanks!
So i’m running into the same predicament. CPT from an events plugin that I have extended the api and I need to get to the featured image.
I’ve tried including the example.com/wp-json/wp/v2/[cpt]/655?_embed param but I just get the 403 response in my original call.
featuredmedia":[{"code":"rest_forbidden","message":"You don't have permission to do this.","data":{"status":403}}]
Has anyone come up with a way to get at the featured images that are tucked on non standard posts?
Not ideal but I was able to get around it by generating a application password which our api will use using this plugin – https://github.com/georgestephanis/application-passwords.
I was able to query the media element after that.
The problem seems not to be fixed until now. Any plans? It’s very annoying…
Thanks!
Is anyone working on this? It’s most definitely not resolved.
I’m using the following plugin to workaround this problem:
https://wordpress.org/plugins/better-rest-api-featured-images/
It works fine. But it would be better if the original plugin has this functionality.
Agreed, not sure why this is marked as resolved, as we’re coming across it still.
Hi! When I share my website link to facebook, the title is 403 Forbidden. Directly on my website http://www.missqueenportugal.com/ I didn’t saw any kind of 403 forbidden message. I tried a lot of
advises I found, as removing .htaccess file, desactivating all the plugins and also checked permissions. I tried to debug at facebook
debugger, but the informations doesn’t change. Anyone can help me to fix this problem?