Hi,
I'm working on modifying Discuz forum code to fit my purposes. One major change is about image zoom. The original setting is that when an image is wider than screenwidth*0.7, it will be automatically zoomed to *0.7. I want to disable zoom function, display images with original size.
Here is the code to display image attachment:
- PHP: Select all
<!--{if !$attach['price'] || $attach['payed']}-->
<!--{if $attach['thumb']}-->
<!--{if ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl'])}-->
<a href="attachment.php?aid=$attach[aid]&noupdate=yes&nothumb=yes" target="_blank"><img src="attachment.php?aid=$attach[aid]" border="0" alt="{lang image_thumb}" /></a>
<!--{else}-->
<a href="$attach[url]/$attach[attachment]" target="_blank"><img src="$attach[url]/$attach[attachment].thumb.jpg" border="0" alt="{lang image_thumb}" /></a>
<!--{/if}-->
<!--{else}-->
<!--{if ($attachrefcheck || $attach['remote']) && !($attach['remote'] && substr($ftp['attachurl'], 0, 3) == 'ftp' && !$ftp['hideurl'])}-->
<img src="attachment.php?aid=$attach[aid]&noupdate=yes" border="0" onload="attachimg(this, 'load', '{lang image_open_zoom}')" onmouseover="attachimg(this, 'mouseover')" onclick="attachimg(this, 'click', 'attachment.php?aid=$attach[aid]')" onmousewheel="return imgzoom(this)" alt="" />
<!--{else}-->
<img src="$attach[url]/$attach[attachment]" border="0" onload="attachimg(this, 'load', '{lang image_open_zoom}')" onmouseover="attachimg(this, 'mouseover')" onclick="attachimg(this, 'click', '$attach[url]/$attach[attachment]')" onmousewheel="return imgzoom(this)" alt="" />
<!--{/if}-->
<!--{/if}-->
<!--{/if}-->
And here is the related javascript code about zoom, in "common.
js":
- PHP: Select all
function attachimg(obj, action, text) {
if(action == 'load') {
if(obj.width > screen.width * 0.7) {
obj.resized = true;
obj.width = screen.width * 0.7;
obj.alt = text;
}
obj.onload = null;
} else if(action == 'mouseover') {
if(obj.resized) {
obj.style.cursor = 'hand';
}
} else if(action == 'click') {
if(!obj.resized) {
return false;
} else {
window.open(text);
}
}
}
I have tried to changed
- PHP: Select all
if(obj.width > screen.width * 0.7)
into
- PHP: Select all
if(obj.width > screen.width * 3)
After that, large images don't zoom any more, but I still want more:
1, since image is wider than screen, there should be a horizontal scrollbar in browser window. But it never happens.
2, when there comes such a large LINKED image (with vB code [img]) ----not attachment image---- if "mouseover", the image will be zoomed..... (attachment image is ok). How to fix this?
All in all, I want to achieve: all wide pictures do not zoom. And a horizontal scrollbar shows to fit the widest picture.
I'm new to javascript. Just read some basics, and can not find out what's wrong. So please help with this .
Thanks.