- 积分
- 1181
- 注册时间
- 2012-5-10
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2014-5-31 10:23
|
显示全部楼层
siyeclover 发表于 2014-5-30 23:05
我怎么记得之前我改过宽度了?
今天不改了,等我明天外边玩回来再说。
昨天忘了一点,主楼那个通过改JS函数来缩略图片的方法,仅限于外链图片(图床不是本站),本站的附件图不是靠JS缩略的,要实现自适应缩放,还得另外改。
嗯,附件图这边要改三个地方:
1、\source\function\function_attachment.php
将
function attachwidth($width) {
global $_G;
if($_G['setting']['imagemaxwidth'] && $width) {
return 'class="zoom" onclick="zoom(this, this.src, 0, 0, '.($_G['setting']['showexif'] ? 1 : 0).')" width="'.($width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'] : $width).'"';
} else {
return 'thumbImg="1"';
}
}
替换为
function attachwidth($width, $maxw = 0) {
global $_G;
if($maxw && $_G['setting']['imagemaxwidth'] && $width){
$minw = $width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'] : $width;
$minw = $maxw > $minw ? $minw : $maxw;
return 'class="zoom" onclick="zoom(this, this.src, 0, 0, '.($_G['setting']['showexif'] ? 1 : 0).')" width="'.$minw.'"';
} elseif($_G['setting']['imagemaxwidth'] && $width) {
return 'class="zoom" onclick="zoom(this, this.src, 0, 0, '.($_G['setting']['showexif'] ? 1 : 0).')" width="'.($width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'] : $width).'"';
} else {
return 'thumbImg="1"';
}
}
2、\template\default\forum\viewthread.htm
将
<td class="plc ptm pbn">
<!--{if !IS_ROBOT}-->
替换为
<td class="plc ptm pbn" id="maxwidth">
<script type="text/javascript">
function setcookie2(name, value, expires) {
var curcookie = name + "=" + encodeURI(value)
+((expires) ? ";expires=" + expires.toGMTString() : "");
document.cookie = curcookie;
}
function savecookie2(name, value) {
var now = new Date();
now.setDate( now.getDate() + 180);
setcookie2(name, value, now);
window.location.href=window.location.href;
}
function readcookie2(){
var widthvalue=0;
var allcookies=document.cookie;
var pos=allcookies.indexOf("maxw=");
if(pos!=-1) widthvalue=allcookies.substring(pos).split(";")[0].split("=")[1];
return widthvalue;
}
var maxwidth = document.getElementById("maxwidth").offsetWidth - 40;
lastwidth = readcookie2();
if(lastwidth == 0 || lastwidth != maxwidth) savecookie2("maxw", maxwidth);
</script>
<!--{if !IS_ROBOT}-->
3、\template\default\forum\discuzcode.htm
将所有的
$widthcode = attachwidth($attach['width']);
(共3个)
替换为
$widthcode = attachwidth($attach['width'],$_COOKIE['maxw']);
|
|