I'm working with the new media manager, and have a little issue to retrieve the attachment of the post. I'm developing a plugin which needs to retrieve all attachments of specific posts.
I first thought of using the following code :
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => 'inherit', 'post_parent' => $id ); $attachments = get_posts($args);
The issue though, is that this will retrieve the attachment that I have uploaded in this specific post, not the one I current use.
For example let's say I have three posts. When I created the first post I've directly uploaded all the images that I would need for the three posts, but only use some of them for the actual post as ACF or gallery. The issue is that when I run the above code, I will have an array with all attachments of the three posts when searching attachments for my first post, and none when searching attachments for the second and third posts. Even though I'm using some images for these last posts.
So does anyone have an idea how I can retrieve all the images actually used in a post and not the images that have been attached to this post?