I'm using CakePHP and a custom file browser, alongside TinyMCE.
Here's my callback:
<script type="text/javascript">
function fileBrowserCallBack(field_name, url, type, win) {
browserField = field_name;
browserWin = win;
window.open('/controller/mupload', 'browserWindow', 'modal,width=600,height=500,scrollbars=yes');
}
tinyMCE.init({
mode : 'textareas',
theme : 'advanced',
// theme specific stuff
file_browser_callback: 'fileBrowserCallBack',
width: '620',
height: '380',
relative_urls : false
});
</script>
My window.open in the callback refers to my upload script, in CakePHP. This uploads, and displays images perfectly. When I select an image, the path to the image appears in TinyMCE's Image URL field - all appears like it's working.
I then click Insert, and TinyMCE adds this HTML:
<p><img border="0" /></p> - completely ignoring the path to the image - even though it is set.
If I then click "Insert Image", and browse to another one (or the same), and then select insert, the image appears perfectly, with the correct path, as you would expect.
I can provide more code, but not a live link unfortunately.
So - to summarise, the first time I attempt to insert an image, it inserts an invalid tag. The second time, it works perfectly.
Firebug shows no errors.
Any suggestions?
TinyMCE version:
majorVersion:"3",
minorVersion:"4.2",
releaseDate:"2011-04-07"
Thank you.