#00AF33
Official Code Helper
19529
0
1
Nov 19, 2012 14:18:28 GMT -8
Todge
**
17,323
January 2004
todge
|
Post by Todge on Mar 14, 2007 17:11:33 GMT -8
I know there are already a couple of existing codes to do this, but both have issues, particularly with FF, this addresses these issues..
It also tells you how much the image is reduced by makes it clickable to view it full size in a new window..
It goes in your Global Footer..
<script type="text/javascript"> <!-- /* Modify image size to fit forum By Todge Please keep this header intact */
var picWidth = '550'; //Maximum image width.. var picHeight = '350'; //Maximum image height..
var pics = document.images;
if(window.addEventListener) { window.addEventListener('load', imageSize, false); } else if(window.attachEvent) { window.attachEvent('onload', imageSize); } else { window.onload = imageSize; }
function imageSize() { var p=pics.length-1; while(p>-1) { if(pics[p].alt=='[image] ') { if(pics[p].width>picWidth || pics[p].height>picHeight) { var thisPicWidth = picWidth; if(pics[p].height/(pics[p].width/picWidth)>picHeight) { thisPicWidth = pics[p].width/(pics[p].height/picHeight) } var newWidth = 100-parseInt(thisPicWidth/pics[p].width*100); var picLoaded = document.createElement('A'); picLoaded.setAttribute('href',pics[p].src); picLoaded.setAttribute('target','_blank'); picLoaded.innerHTML = '<font size="0">This image is reduced by '+newWidth+'%, click it to view full size.</font><br><img src="'+pics[p].src+'" width="'+thisPicWidth+'" border="0">'; pics[p].parentNode.replaceChild(picLoaded,pics[p]); }} p--; }} // --> </script>
|
|