I have the following code inside a plugin in a loop, so there are multiple WYSIWYG editors:
<?php wp_editor( stripslashes($arr['item-content']), $key.'-item-content', array(
'editor_class' => 'tsort-contarea',
'media_buttons' => true,
'editor_height' => 360,
) ); ?>
When adding an image, the XHR request labelled send-attachment-to-editor
inside wp-includes/js/media-editor.js
has a wp.media.view.settings.post.id
of 0. Also, wp.media.view.settings.nonce.sendToEditor
is always this value: e8b2eea867
return wp.media.post( 'send-attachment-to-editor', {
nonce: wp.media.view.settings.nonce.sendToEditor,
attachment: options,
html: html,
post_id: wp.media.view.settings.post.id
});
The xhr request fires off fine, but doesn’t add to any of the WYSIWYG. I’m sure that’s because the post_id isn’t set or because the nonce is not unique. What can I do to make this work? The Media Manager works absolutely fine on content pages.
Source file: http://pastebin.com/BhvqBLGB
From Codex:
From what I see you are currently using a dash. Try changing that, and see how that works.
You should check thoroughly for the
wp.media.view.settings.post.id
is 0 part, as I tried to reproduce the bug inmetabox
with multipleeditors
and I get post-id for the new post equal to non-zero (which is actually anauto-draft
record inwp_posts
table), image assignment is working properly for this case.I believe there is something wrong with saving new post as
auto-draft
in your instance of WordPress (might be because of some plugin/theme)