口厄... 你確定你要的是固定把圖縮成400 * 400而不是
按比例縮放,例如800 * 600縮成400 * 300?
這個版本是把寬度多於400的固定縮成400 * 400:
代碼: 選擇全部
<script type="text/javascript">
// <![CDATA[
window.onload = function()
{
var width_constraint = 400;
if (document.getElementsByTagName)
{
for (i=0; i<document.getElementsByTagName('img').length; i++)
{
im = document.getElementsByTagName('img')[i];
if (im.parentElement.className != 'content' &&
im.parentElement.className != 'attach-image')
continue;
if (im.width > width_constraint)
{
//im.style.height = ((width_constraint * im.height) / im.width) + "px";
im.style.height = width_constraint + "px";
im.style.width = width_constraint + "px";
eval("pop" + String(i) + " = new Function(\"pop = window.open('" + im.src + " ','fullscale','width=" + width_constraint + ",height=400,scrollbars=1,resizable=1'); pop.focus();\")");
eval("im.onclick = pop" + String(i) + ";");
if (document.all) im.style.cursor = 'hand';
if (!document.all) im.style.cursor = 'pointer';
im.title = '按此, 觀看完整大小的圖片';
}
}
}
}
// ]]>
</script>
這個則是按比例縮放:
代碼: 選擇全部
<script type="text/javascript">
// <![CDATA[
window.onload = function()
{
var width_constraint = 400;
if (document.getElementsByTagName)
{
for (i=0; i<document.getElementsByTagName('img').length; i++)
{
im = document.getElementsByTagName('img')[i];
if (im.parentElement.className != 'content' &&
im.parentElement.className != 'attach-image')
continue;
if (im.width > width_constraint)
{
im.style.height = ((width_constraint * im.height) / im.width) + "px";
im.style.width = width_constraint + "px";
eval("pop" + String(i) + " = new Function(\"pop = window.open('" + im.src + " ','fullscale','width=" + width_constraint + ",height=400,scrollbars=1,resizable=1'); pop.focus();\")");
eval("im.onclick = pop" + String(i) + ";");
if (document.all) im.style.cursor = 'hand';
if (!document.all) im.style.cursor = 'pointer';
im.title = '按此, 觀看完整大小的圖片';
}
}
}
}
// ]]>
</script>
把這段code放在styles/你的風格/template/viewtopic_print.html裡面
代碼: 選擇全部
<title>{SITENAME} • {PAGE_TITLE}</title>
這一段底下就可以了。