Reputation: 129
I'm making a Wordpress plugin for adding image maps in the posts. Currently I have implemented the image maps as a custom post types. However I'm having some trouble with adding them in posts.
I have made a new tab in the media insert/upload window called Image map. When you click an image map in the tab, this function is fired:
function insertImageMap() {
tinyMCE.execInstanceCommand('mceInsertContent', false, 'content',
'some text or html code'
);
window.parent.tb_remove();
}
However nothing is added to the tinyMCE editor. The function is fired, but the instance of tinyMCE editor is undefined even if I use tinyMCE.getInstanceById('content'). Is there a way to access the editor of a post editor page?
I have included tinyMCE script in my plugin and it doesn't show as undefined.
I found an older question asking the same, but the answer wasn't very helpful: Custom Wordpress Plugin - How do I insert content from popup on post editor?
Upvotes: 3
Views: 2910
Reputation: 129
Solution found in comments:
function insertImageMap() {
window.parent.send_to_editor('any text');
window.parent.tb_remove();
}
Upvotes: 9