Search code examples
jquerytinymceuploadify

Add image uploaded with uploadify to tinymce textarea


I'm trying to build a script that would allow me to post articles. The user should be allowed to add images at the end of the article. I would like to solve this by allowing the user to write the article first and then upload some images. When the images are uploaded, they should automatically be added at the end of the tinymce textarea. I get the filename, but don't know how to add it to the Tinymce. I tried with jquery's append, but it doesn't work.

Thank you for your answers :)


Solution

  • I implemented a similar solution by handling the upload operation in a tinyMCEPopup window. Once the upload is complete and I have the filename, I call the following command and then close the popup.

    tinyMCEPopup.execCommand('mceInsertContent', false, imgSrc);
    tinyMCEPopup.close();
    

    imgSrc is the path of the image.