我正在使用这个很棒的编辑器,但我不知道如何使用imageUpload和clipboardUpload传递额外的参数。
我希望能够在用户将图像传入编辑器时发布额外的参数
$el.redactor({
imageUpload: '/WebUpload/Save',
clipboardUploadUrl: '/WebUpload/Save',
});
从Redacor v10开始,包含额外的参数
只需使用uploadImageFields
$el.redactor({
imageUpload: '/WebUpload/Save',
clipboardUploadUrl: '/WebUpload/Save',
uploadImageFields: {
id: 1234,
name: "test123"
},
});
答案 0 :(得分:2)
无法在任何地方找到答案,所以我攻击了核心redactor.js文件
我添加了
$.Redactor.opts = {
imageUploadExtraParams: {},
选项并更改帖子以在pasteClipboardUploadMozilla
和pasteClipboardUpload
pasteClipboardUploadMozilla: function() {
var imgs = this.$editor.find('img[data-mozilla-paste-image]');
$.each(imgs, $.proxy(function(i, s) {
var $s = $(s);
var arr = s.src.split(",");
var data = arr[1]; // raw base64
var contentType = arr[0].split(";")[0].split(":")[1];
var postData = {
contentType: contentType,
data: data,
};
var extraParams = this.opts.imageUploadExtraParams || {};
for (var propName in extraParams) {
postData[propName] = extraParams[propName];
}
$.post(this.opts.clipboardUploadUrl, postData,
并更改了
pasteClipboardUploadMozilla: function() {
var imgs = this.$editor.find('img[data-mozilla-paste-image]');
$.each(imgs, $.proxy(function(i, s) {
var $s = $(s);
var arr = s.src.split(",");
var data = arr[1]; // raw base64
var contentType = arr[0].split(";")[0].split(":")[1];
var postData = {
contentType: contentType,
data: data,
};
var extraParams = this.opts.imageUploadExtraParams || {};
for (var propName in extraParams) {
postData[propName] = extraParams[propName];
}
$.post(this.opts.clipboardUploadUrl, postData,
现在我可以通过添加imageUploadExtraParams
对象
$el.redactor({
imageUpload: '/WebUpload/Save',
clipboardUploadUrl: '/WebUpload/Save',
imageUploadExtraParams: {
id: 1234,
name: "test123"
},
});
从Redacor v10开始,包含额外的参数
只需使用uploadImageFields
$el.redactor({
imageUpload: '/WebUpload/Save',
clipboardUploadUrl: '/WebUpload/Save',
uploadImageFields: {
id: 1234,
name: "test123"
},
});