我正在使用Kendo版本Kendo.Mvc,版本= 2015.2.902.545
我想在kendo EditorFor中将我的图像转换为 Base64 格式, 但是它不支持以上版本的URLHandler。 下面是脚本和剑道图像浏览器
Kendo图像浏览器代码:
@(Html.Kendo().EditorFor(model => model.Text)
.Name(Model.Name)
.HtmlAttributes(new { style = "width:100%; height:200px", id = Model.Id })
.ImageBrowser(imageBrowser => imageBrowser
.Image("~/Content/UserFiles/Images/{0}")
.Read("Read", "ImageBrowser")
.Create("Create", "ImageBrowser")
.Destroy("Destroy", "ImageBrowser")
.Upload("Upload", "ImageBrowser")
.Thumbnail("Thumbnail", "ImageBrowser"))
.Events(e => e.Change(changedEventName))
.Encode(false)
.Tools(tool => tool.ViewHtml())
//.Tools(tool => tool.FontSize())
//.Tools(tool => tool.FontName())
// Oliver added on 27 June 2018. To enable the subscript and superscript function
.Tools(tool => tool.SubScript())
.Tools(tool => tool.SuperScript())
.Tools(tool => tool.FontColor())
.StyleSheets(s => s.Add("/Content/KendoEditorStyle.css"))
)
脚本:
<script>
function imageUrlFn(path) {
var result = "";
$.ajax({
async: false,
url: "/ImageBrowser/GetImage",
data: {
path: path
},
success: function (data) {
result = data;
}
});
return result;
}
</script>
控制器:
public ActionResult GetImage(string path)
{
Byte[] currentFile = System.IO.File.ReadAllBytes(Server.MapPath(Path.Combine(contentFolderRoot, "UserFiles", imagesFolder) + path));
if (currentFile == null) return HttpNotFound();
String file = Convert.ToBase64String(currentFile);
return Json("data:image/png;base64," + file, JsonRequestBehavior.AllowGet);
}
我需要以下问题的帮助,例如如何在图像浏览器中传递函数,因为它也不需要.CustomButton或单击插入按钮时发生的类似事件的事件,当我们选择图像图标时会弹出该按钮。
感谢和问候Tejas