开发者

tinymce image insert, works second time but not the first

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.


This supposedly was answered in their ticket: http://tinymce.moxiecode.com/develop/bugtracker_view.php?id=4427

But this was reported in: http://tinymce.moxiecode.com/develop/bugtracker_view.php?id=4499

Some fixes at http://tinymce.moxiecode.com/forum/viewtopic.php?id=25646


I fixed this by setting the convert_urls config to false.

See here for more info on that config and related config: https://www.tiny.cloud/docs/configure/url-handling/#qhowdoiconvertmyurlstorelativeabsoluteorabsolutewithdomain

convert_urls

This option enables you to control whether TinyMCE is to be smart and restore URLs to their original values. URLs are automatically converted (messed up) by default because the browser’s built-in logic works this way. There is no way to get the real URL unless you store it away. If you set this option to false it tries to keep these URLs intact. This option is set to true by default, which means URLs are forced to be either absolute or relative depending on the state of relative_urls.
Type: Boolean

Default Value: true

relative_urls For URLs with the same domain as the page containing the TinyMCE editor. If set to:

true — All URLs created in TinyMCE will be converted to a link relative to the document_base_url.
false — All URLs will be converted to absolute URLs.

Type: Boolean

Default Value: true

document_base_url

This option specifies the base URL for all relative URLs in the document. The default value is the directory of the current document. If a value is provided, it must specify a directory (not a document) and must end with a /.

This option also interacts with the relative_urls, remove_script_host, and convert_urls options to determine whether TinyMCE returns relative or absolute URLs. The FAQ contains a thorough description and examples of working with relative and absolute URLs.

Type: String
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜