I'm trying to upload an attachment using the "Add Media" button placed right above the editor.
The request goes to the
I can put a
var_dump($_REQUEST); call there.
Whenever I upload an attachment for a regular post, the
$_REQUEST contains the post_id key and the attachment has that post saved as it's
But when I do the same for a custom post type I've created, the
post_id key is missing. I have no idea why.
Tried adding XHR breakpoints to that upload request, but they all lead to the minified plupload.full.min.js code that seems abstracted from whatever data is being passed through it. I tried searching for the entry point where it starts that upload (and probably has some condition on whether to include the post id) but couldn't find it.
A hidden input with the correct
post_id is present on both pages.
When I call
media_handle_upload('file', $post_id); from elsewhere in the code, the file gets attached as expected.
Why do the custom post type upload requests omit the post_id? Am I missing something in the post type declaration?