Ok this seems to have fixed it:
function wp_plupload_include_attachment_id( $params ) {
global $post_ID;
if ( isset( $post_ID ) )
$params['post_id'] = (int) $post_ID;
return $params;
}
add_filter( 'plupload_default_params', 'wp_plupload_include_attachment_id' );
This preprocesses the uploader $params
and makes sure the post_id
is included.
Taken from here: https://core.trac.wordpress.org/attachment/ticket/22085/media.php.patch