Код очень простой:
JavaScript функция, которая уменьшает/разворачивает картинку
Код: Выделить всё
function imgFit (img, maxImgWidth)
{
if (typeof img.naturalWidth == 'undefined') {
img.naturalHeight = img.height;
img.naturalWidth = img.width;
}
if (img.width > maxImgWidth) {
img.height = Math.round(((maxImgWidth)/img.width)*img.height);
img.width = maxImgWidth;
img.title = 'Click image to view full size';
img.style.cursor = 'move';
} else if (img.width == maxImgWidth && img.width < img.naturalWidth) {
img.height = img.naturalHeight;
img.width = img.naturalWidth;
img.title = 'Click to fit in the browser window';
}
}
Дальше картинке, которую нужно уменьшить, добавляем
где maxImgWidth - максимальная ширина картинки в пикселях.onload="imgFit(this, maxImgWidth);" onclick="imgFit(this, maxImgWidth);"
В данном случае нужно сжать картинку так, чтобы не распирало страницу. Поэтому maxImgWidth будет равен screen.width-180 (180 -- примерная ширина левой колонки с аватарами).
В bbcode.tpl это выглядит так
Код: Выделить всё
<!-- BEGIN img --><img src="{URL}" border="0" onload="imgFit(this, screen.width-180);" onclick="imgFit(this, screen.width-180);" alt="" /><!-- END img -->
Живой пример
http://torrents.ru/forum/viewtopic.php?t=13828
login: test/123