inherit
Proboards Legend
212
0
May 11, 2006 12:32:55 GMT -8
california
21,035
December 1999
california
|
Post by california on Jun 22, 2005 21:36:56 GMT -8
Tired of n00bs posting huge images that stretch out the width of the board? Worry no more This code will automatically resize all posted/sig images that have dimensions greater than either of the ones you specify, but keep their proportions correct. <script type="text/javascript"> <!-- /* set max posted image size with click to enlarge by california */
var maxWidth=500; var maxHeight=300;
var img=document.getElementsByTagName("img"); for(i=0;i<img.length;i++){ if(img.alt.match(/\[image\]/i)){ img.onload=function(){ if(this.width>maxWidth){ this.style.height=""+(this.height*maxWidth/this.width)+"px"; this.style.width=""+maxWidth+"px"; this.style.cursor="pointer"; this.onclick=function(){ window.open(this.src,'imgwin',''); } } if(this.height>maxHeight){ this.style.width=""+(this.width*maxHeight/this.height)+"px"; this.style.height=""+maxHeight+"px"; this.onclick=function(){ window.open(this.src,'imgwin',''); } } } } } // --> </script> Global Footer Update 13 July '05: Code now resizes all images after they are done loading, so no images should be skipped and they shouldn't need to be cached anymore. Update 29 July '05: Added back the click to enlarge feature.
|
|