Discuz X3.2后台有图片水印功能,当设置了添加水印,在发布文章时候会自动给上传的图片添加上水印,但是一些主题会生成缩略图,缩略图确无法自动添加水印,如何处理?
注:此方法适用于X系列版本,不限于3.2 ,X2.5同样适用。其他版本自测。
解决办法
打开 source\function\function_post.php
这个文件,找到以下代码
$image->Watermark($_G['setting']['attachdir'].'/forum/'.$newattachfile[$aid], '', 'forum');
在这段代码的上方
加入
// 缩略图打水印
if (file_exists($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid] . '.thumb.jpg')) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $newattachfile[$aid] . '.thumb.jpg', '', 'forum');
}
// 缩略图打水印end
然后继续查找
C::t('forum_attachment_unused')->delete($aid);
在上面这段打开的上方,继续添加
// 缩略图打水印
if (file_exists($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'] . '.thumb.jpg')) {
$image->Watermark($_G['setting']['attachdir'] . '/forum/' . $attach['attachment'] . '.thumb.jpg', '', 'forum');
}
// 缩略图打水印结束
修改后保存或者上传,这样就可以自动为文章的缩略图打上水印了。