gpt4 book ai didi

javascript - 独立 CKFinder : how to only select images in file dialog popup?

转载 作者:行者123 更新时间:2023-11-28 09:01:13 25 4
gpt4 key购买 nike

我将 CKFinder 与 CKEditor 结合使用,但也作为独立的文件输入图像弹出窗口。因此,当有人单击“上传”按钮时,会出现一个新的弹出窗口,用户可以在其中选择要上传的图像/文件/Flash 文件。对于“头像”字段,我只需要选择图像文件。应该不可能选择其他文件类型。我怎样才能让它发挥作用?在文档中我找不到非常有用的信息。

在 CKEditor 中,只能从 CKFinder 弹出窗口中选择图像或文件,但看起来在独立版本的 CKFinder 中已经忘记了相同的选项。我需要实现“ckfinder.html?type=Image”,但我不想修改 ckfinder.js,因为这也会影响其他文件弹出对话框,在这些对话框中,某人甚至应该能够选择图像作为文件。

我在弹出示例中包含了 CKFinder:

var finder = new CKFinder();
finder.basePath = '../'; // The path for the installation of CKFinder (default = "/ckfinder/").
finder.selectActionFunction = SetFileField;
finder.popup();

预先感谢您的帮助!

最佳答案

你应该尝试一下,*

LoadImage

是按钮选择文件的id,

picUrl

是文本链接的id

$('#LoadImage').click(function () {
var finder = new CKFinder();
finder.selectActionFunction = function (fileUrl) {
fileUrl = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
$('#picUrl').val = (fileUrl);
}
selectFileWithCKFinder('picUrl');
})
function selectFileWithCKFinder(elementId) {
CKFinder.popup({
chooseFiles: true,
width: 800,
height: 600,
onInit: function (finder) {
finder.on('files:choose', function (evt) {
var file = evt.data.files.first();
var output = document.getElementById(elementId);
output.value = file.getUrl();
});

finder.on('file:choose:resizedImage', function (evt) {
var output = document.getElementById(elementId);
output.value = evt.data.resizedUrl;
});
}
});
}

关于javascript - 独立 CKFinder : how to only select images in file dialog popup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17709348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com