phpcms v9编辑器上传图片是否添加水印

本文详细介绍了如何在CKEditor中实现图片上传对话框的水印添加功能,包括修改JavaScript文件、PHP文件以及相关类的方法。通过三个步骤进行操作,确保用户在上传图片时能够选择是否添加水印。

第一步:给图片上传对话框里面添加是否添加水印的多选框,找到:

satics/js/ckeditor/ckeditor.js 第17554行 (需要格式化,我用的NetBeans)修改为

function D(){
w.$.open();
if(b.isCustomDomain())w.$.domain=document.domain;
var E='';
if(x.size)E=x.size-(c?7:0);
var F=u.frameId+'_input';
w.$.write(['<html dir="'+B+'" lang="'+C+'"><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">','<form enctype="multipart/form-data" method="POST" dir="'+B+'" lang="'+C+'" action="',e.htmlEncode(x.action),'">','<label id="',u.labelId,'" for="',F,'" style="display:none">',e.htmlEncode(x.label),'</label>','<input id="',F,'" aria-labelledby="',u.labelId,'" type="file" name="',e.htmlEncode(x.id||'cke_upload'),'" size="',e.htmlEncode(E>0?E:''),'" />','<input type="checkbox" name="', e.htmlEncode('watermarks_enable'), '" size="', e.htmlEncode(E > 0 ? E: ''), '" />是否添加水印','</form>','</body></html>','<script>window.parent.CKEDITOR.tools.callFunction('+z+');','window.onbeforeunload = function() {window.parent.CKEDITOR.tools.callFunction('+A+')}</script>'].join(''));
w.$.close();
for(var G=0;G<y.length;G++)y[G].enable();
};

添加了红色部分

第二步:修改 phpcms/libs/classes/image.class.php 第16行

    function __construct($thumb_enable = 0 ,$water_enable = 0, $siteid)

    修改 phpcms/libs/classes/image.class.php 第18行和20行

    $this->water_enable = $water_enable;  (第18行)

    $this->watermark_enable = $this->water_enable;(第20行)

 

第三步:修改 phpcms/libs/classes/attachment.class.php 第35行 修改为:

       将upload方法最后一个参数改为 $watermark_enable = 0

       同时在39行下面空白的地方增加:

      $watermark_enable = isset($_POST['watermarks_enable'])? 1 : $watermark_enable;

      继续修改:第123行 实例化image类的时候的参数 改为:

      $image = new image($thumb_enable,$watermark_enable,$this->siteid);

(来自转载)

转载于:https://www.cnblogs.com/hshanghai/p/3956392.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值