Needed to call wp_enqueue_media() on the 'admin_enqueue_scripts' hook. Otherwise uploading media would not be attached to the post when done from the Edit Post screen.