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?

  • 写回答

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."\")' />"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制