TinyMCE图像URL选择

时间:2011-06-30 16:03:34

标签: file-upload tinymce

我为TinyMCE编写了自己的图片上传器,但我有一个两难选择:如何选择要在TinyMCE advimage弹出窗口的“图像URL”字段中显示的图像?

当我点击“图片网址”字段旁边的按钮时,我的图片上传器会在另一个弹出窗口中打开。所以我需要从弹出窗口中获取图像URL并将其插入该字段中的另一个弹出窗口。我可以很容易地获得路径,但我不知道如何将其插入到其他地方。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我正在使用jQuery构建,这是我在自定义文件浏览器中使用的代码的一部分:

$('.my-image').click(function() {// Change this to your event/selector

    var $src = $(this).val();// Change this to whatever the image path is
    if ( ! $src) return false;

    // Find the iframe within the popup
    var $input = $(window.top.document)
    .find('iframe[src*="advimage/image.htm"]')
    .contents()
    .find('input#src');

    // Trigger the preview and fill in the image dimensions
    $input.val($src).change();

    return false;
});

也许不是最优雅的解决方案,但多年来它一直在为我工作。希望这会有所帮助。