设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 2865|回复: 7
收起左侧

Discuz! X 图片上传后水印位置随机显示的实现方法

[复制链接]
发表于 2018-1-16 08:34:53 | 显示全部楼层 |阅读模式
打开文件 source\class\class_image.php 查找以下代码:


  1.                         switch($this->param['watermarkstatus'][$type]) {
  2.                                 case 1:
  3.                                         $x = 5;
  4.                                         $y = 5;
  5.                                         break;
  6.                                 case 2:
  7.                                         $x = ($this->imginfo['width'] - $logo_w) / 2;
  8.                                         $y = 5;
  9.                                         break;
  10.                                 case 3:
  11.                                         $x = $this->imginfo['width'] - $logo_w - 5;
  12.                                         $y = 5;
  13.                                         break;
  14.                                 case 4:
  15.                                         $x = 5;
  16.                                         $y = ($this->imginfo['height'] - $logo_h) / 2;
  17.                                         break;
  18.                                 case 5:
  19.                                         $x = ($this->imginfo['width'] - $logo_w) / 2;
  20.                                         $y = ($this->imginfo['height'] - $logo_h) / 2;
  21.                                         break;
  22.                                 case 6:
  23.                                         $x = $this->imginfo['width'] - $logo_w;
  24.                                         $y = ($this->imginfo['height'] - $logo_h) / 2;
  25.                                         break;
  26.                                 case 7:
  27.                                         $x = 5;
  28.                                         $y = $this->imginfo['height'] - $logo_h - 5;
  29.                                         break;
  30.                                 case 8:
  31.                                         $x = ($this->imginfo['width'] - $logo_w) / 2;
  32.                                         $y = $this->imginfo['height'] - $logo_h - 5;
  33.                                         break;
  34.                                 case 9:
  35.                                         $x = $this->imginfo['width'] - $logo_w - 5;
  36.                                         $y = $this->imginfo['height'] - $logo_h - 5;
  37.                                         break;
  38.                         }
复制代码



将上方所有代码注释,并加入以下代码保存即可:

  1. $x = rand(0,($this->imginfo['width'] - $logo_w));
  2. $y = rand(0,($this->imginfo['height'] - $logo_h));
复制代码

修改前最好备份,出现错误会造成图片无法上传处理等问题。


相关帖子

发表于 2018-1-16 10:18:14 | 显示全部楼层
还不错,路过好了。
发表于 2018-1-17 09:53:27 | 显示全部楼层
看看啥玩意了
发表于 2018-1-26 14:32:18 | 显示全部楼层
水印位置随机啊...其实影响观看的心情。
发表于 2018-4-11 17:17:45 | 显示全部楼层
优先级,如果您要查看本帖隐藏内容请回复
发表于 2018-10-13 00:19:21 | 显示全部楼层
看看咋搞的
您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-27 12:34 , Processed in 1.522087 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表