1
votes

Hey guys so I use tinymce, I have a separate image uploader I built that when you upload an image displays the thumb nail and an add button below the text area. The add button runs the following onclick:

tinyMCE.execCommand("mceInsertContent", false, "<img style='width:50px;height:50px;' src='images/temp/"+val1+"/"+val2+".jpg' alt='' />");

Where val1 is the image folder and val2 is the img number

I have a preview function which posts to a copy of the index page for preview, here is the post from the URL for the text area.

&15=<ul><li>point%201</li><li>point%202</li><li>point%203</li></ul><p>&nbsp;</p><p>
<img%20style="width:%2050px;%20height:%2050px;"%20src="images/temp/45991210/3.jpg"%20alt=""%20/></p>

This is 3 points and the image, but the image does not work?? the html creates the 3 points and then an empty p tag, if i dnt have the 3 previous points then it does work:

&15=<p><img%20style="width:%2050px;%20height:%2050px;"%20src="images/temp/45991210/3.jpg"%20alt=""%20/></p>

I don't understand why. can anyone assist me please.

EDIT: Iv managed to narrow it down to the &nbsp that is causing the issue. Its due to the & in a URL post

1

1 Answers

0
votes

Try to escape your input before sending it to tinyMCE.execCommand:

tinyMCE.execCommand("mceInsertContent", false, escape("<img style='width:50px;height:50px;' src='images/temp/"+val1+"/"+val2+".jpg' alt='' />"));