1、rails_kindeditor 的初始化集成请参考:https://github.com/Macrow/rails_kindeditor 2、rails_kindeditor 默认上传路径是项目 public 目录下,而我们有单独的上传图片接口,所以就把项目中 rails_kindeditor.rb 中的 config.upload_dir 这行注释掉了(可忽略),把
$(function(){
KindEditor.create('#item_new_news_contents', {"items":["source","|","undo","redo","|","justifyleft","justifycenter","justifyright","justifyfull","fontname","fontsize","|","forecolor","bold","italic","underline","|","image","multiimage","media","preview"],"width":"100%","height":300,"allowFileManager":true,"uploadJson":"/img/uploadimg?city=123&aa=345&style=test","fileManagerJson":"http://192.168.1.96:2998/kindeditor/filemanager",urlType:'domain'});
})
里面的 uploadJson 修改成自己的图片上传接口,最重要的是返回值要是 Object 类型。
Object {error: 0, url: "http://xxx.com/images/263804351010818/news/285…914/info/31cd5ce8-4f6b-4bbd-96f8-a9ec3f7d9d8b.jpg"}