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

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

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"}
共收到 1 条回复

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

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