Discuz! X 给不同尺寸的图片添加不同大小的水印
分类 网站技术/村民张先生 发布于 2020-01-13 05:24
仅供参考,请根据自己的需要修改。
打开 source/class/class_image.php 文件,
查找:
$this->param['watermarkfile'][$type] = './static/image/common/'.($this->param['watermarktype'][$type] == 'png' ? 'watermark.png' : 'watermark.gif');
替换为:
if($this->imginfo['width']) $wmsize = $this->imginfo['width'] <= 1024 ? '' : ($this->imginfo['width'] <= 1536 ? '_200' : ($this->imginfo['width'] <= 2160 ? '_300' : ($this->imginfo['width'] <= 2880 ? '_400' : ($this->imginfo['width'] <= 3600 ? '_500' : '_500')))); $this->param['watermarkfile'][$type] = './static/image/common/watermark'.$wmsize.($this->param['watermarktype'][$type] == 'png' ? '.png' : '.gif');
修改后,除上传 watermark.png 外,还要上传逐渐放大尺寸的 watermark_200.png, watermark_300.png, watermark_400.png, watermark_500.png 到 static/image/common/ 目录。
欢迎谈谈你的看法(无须登录) *正文中请勿包含"http://"否则将被拦截