首页 > 开发 > PHP > 正文

同一页面放多个百度编辑器 Ueditor 并用PHP获取 Ueditor 的实例

2024-05-04 21:50:30
字体:
来源:转载
供稿:网友

同一页面放多个百度编辑器 Ueditor 并用PHP获取 Ueditor 的值的实例

同一个网页如何放置多个Ueditor?

参考代码如下:

  1. <form  method="post" action="save.php"
  2.  
  3. <script type="text/plain" id="ueditorId_1" name="ueditorName_1" style="width: 400px;height:500px;">编辑器的默认值_1</script> 
  4.  
  5. <script type="text/javascript"
  6.     UE.getEditor('ueditorId_1'); 
  7. </script> 
  8.  
  9. <script type="text/plain" id="ueditorId_2" name="ueditorName_2" style="width: 450px;height:550px;">编辑器的默认值_2</script> 
  10.  
  11. <script type="text/javascript"
  12.     UE.getEditor('ueditorId_2'); 
  13. </script> 
  14.  
  15. </form> 

这样,就会在页面中渲染2个Ueditor编辑器。

PHP如何获取多个Ueditor的值?

注意,上面的 ueditorName_1,ueditorName_2 即为表单的Name值,所以服务端PHP获取Ueditor编辑器的值变得很简单,参考代码如下:

$_POST["ueditorName_1"];  // 第一个编辑器的值

$_POST["ueditorName_2"];  // 第二个编辑器的值

解决百度 ueditor v1.4.3 编辑器上传图片失真的bug? 

项目中,用到百度ueditor编辑器,发现,上传大一点的图片,图片会失真,刚开始还以为是PHP端做了图片压缩,仔细看配置说明,发现是编辑器自带有个自动压缩图片的功能,可恶的是,压缩后的图片失真了!

决定去掉这个压缩功能,如果非得要压缩,那就交给服务端PHP来处理吧!

找到配置文件:ueditor/php/config.json

把 imageCompressEnable 设置为 false 即可!

【总结】有2个比较重要的配置文件:

ueditor/ueditor.config.js

ueditor/php/config.json

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表