Ruby rails_kindeditor 修改默认的图片上传方式

claf1314 · 2016年09月20日 · 最后由 marleyzhang 回复于 2019年08月08日 · 1934 次阅读

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"}

我修改了 还是按照默认的方式放在 public/uploads/image 里面 😂

需要 登录 后方可回复, 如果你还没有账号请 注册新账号