百度编辑器单独作为图片上传文件上传功能,百度编辑器做缩略图

来源:互联网 发布:mac铁锈红是什么色 编辑:程序博客网 时间:2024/06/05 06:06

百度编辑器单独作为图片上传文件上传功能,百度编辑器做缩略图

在做thinkphpcms  的时候,用到百度编辑器, 所以把他单独出来把,使用方法, 把这个复制到自己的项目中, 把两个js 文件,和你的百度编辑器的位置相对应






<html>  <head><script type="text/javascript" src="__PUBLIC__/baiduedit/ueditor.config.js"></script>    //需要修改的<!-- 编辑器源码文件 --><script type="text/javascript" src="__PUBLIC__/baiduedit/ueditor.all.js"></script>    //需要修改的  </head>  <body>          <script type="text/plain" id="j_ueditorupload" style="height:5px;display:none;" ></script>    <script>      //实例化编辑器      var o_ueditorupload = UE.getEditor('j_ueditorupload',      {        autoHeightEnabled:false      });      o_ueditorupload.ready(function ()      {          o_ueditorupload.hide();//隐藏编辑器          //监听图片上传    o_ueditorupload.addListener('beforeInsertImage', function (t,arg)    {          alert('这是图片地址:'+arg[0].src);    });          /* 文件上传监听     * 需要在ueditor.all.min.js文件中找到     * d.execCommand("insertHtml",l)     * 之后插入d.fireEvent('afterUpfile',b)     */        o_ueditorupload.addListener('afterUpfile', function (t, arg)        {          alert('这是文件地址:'+arg[0].url);        });      });              //弹出图片上传的对话框      function upImage()      {        var myImage = o_ueditorupload.getDialog("insertimage");        myImage.open();      }      //弹出文件上传的对话框      function upFiles()      {        var myFiles = o_ueditorupload.getDialog("attachment");        myFiles.open();      }    </script>          <button type="button" onClick="upImage()">调用上传图片模块</button>    <br>    <button type="button" onClick="upFiles()">调用上传文件模块</button>        </body><html>


0 0
原创粉丝点击