dongqigu0429
2010-07-27 10:40
浏览 54
已采纳

CKEditor - 自定义图像浏览器

I'm currently developing a image browser in PHP and jQuery. I've managed to create a custom button plugin that opens my image browser in a new window (not a dialog box):

CKEDITOR.plugins.add('imgbrowser',
{
    init: function(editor)
    {
        var pluginName = 'imgbrowser';
        editor.ui.addButton('Imgbrowser',
            {
                label: 'Image browser',
                command: pluginName,
                click: function (editor) { window.open('/publish/browser/index.php','Image Browser','width=900,height=600'); }
            });
    }
});

Is there anyone here who knows how to enable the callback function and how this will be used so that I can add the selected pictures into the editor?

图片转代码服务由CSDN问答提供 功能建议

我目前正在开发PHP和jQuery的图像浏览器。 我设法创建了一个自定义按钮插件,在新窗口(不是对话框)中打开我的图像浏览器:

  CKEDITOR.plugins.add('imgbrowser',  
 {
 init:function(editor)
 {
 var pluginName ='imgbrowser'; 
 editor.ui.addButton('Imgbrowser',
 {
 label:'Image browser',
 command  :pluginName,
 click:function(editor){window.open('/ publish / browser / index.php','Image Browser','width = 900,height = 600');} 
}); \  n} 
}); 
   
 
 

这里是否有人知道如何启用回调函数以及如何使用它以便我可以添加所选图片 进入编辑器?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douliao8318 2010-07-28 07:20
    已采纳

    Ok. Here is the answer:

    In the parent window I have this function:

    function InsertHTML(file_path)
            {
                // Get the editor instance that we want to interact with.
                var oEditor = CKEDITOR.instances.page_content;
                var value = file_path;
    
                // Check the active editing mode.
                if ( oEditor.mode == 'wysiwyg' )
                {
                    // Insert the desired HTML.
                    oEditor.insertHtml( '<img src="' + value + '" />' );
                }
                else
                    alert( 'You must be on WYSIWYG mode!' );
            }
    

    page_content is the id of my textarea.

    In the popup window I have this function:

    function sendToParent(file_path) {
        window.opener.InsertHTML(file_path);
    }
    
    
    echo "<input type='button' value='Insert image' onclick='sendToParent(\"".$img_element."\")' />"
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题