|
Post by Wormopolis on Aug 9, 2009 6:30:34 GMT -8
Browser Tested: IE and FF placement: global or board footer Will replace any images in posts, as well as a post preview, that exceed size restrictions. replaces links with text, or a link to the image. code: <script type="text/javascript"> <!-- // replace large images with text or link // by Wormopolis - wormocodes.proboards.com // Keep header intact
var maxHeight=700; // leave these as 0 if you dont want a max var maxWidth=640;
var repText="<font color=red><b><center>Image Removed<br/><br/> Max image size is "+maxWidth+" X "+maxHeight+"<br/><br/>Please post smaller image</center></b></font>"; var linkReplace = false; //true if you want text to link to image.
if (location.href.match(/action=(display|recent|search)/) || document.postForm) {
for (tds=document.getElementsByTagName('td'), k=0; k<tds.length; k++) { if (tds[k].width=="80%" && tds[k].align=="left" && tds[k].vAlign=="top" && tds[k].className.match(/windowbg/)) { postArea=tds[k].getElementsByTagName('tr')[1]; pics=postArea.getElementsByTagName('img'); if (pics) { for (p=0; p<pics.length; p++) { nwfnt=document.createElement('font'); if ((maxHeight>0 && pics[p].height>maxHeight) || (maxWidth>0 && pics[p].width>maxWidth)) { nwfnt.innerHTML=(linkReplace ? "<a href="+pics[p].src+" target='_blank'>"+repText+"</a" : repText); pics[p].parentNode.replaceChild(nwfnt,pics[p]); } } } } if (tds[k].className=='titlebg' && tds[k].width=="100%" && tds[k].innerHTML.match(/Topic Summary/)) { summArea=tds[k].parentNode.parentNode.parentNode; pics=summArea.getElementsByTagName('img'); if (pics) { for (p=0; p<pics.length; p++) { nwfnt=document.createElement('font'); if ((maxHeight>0 && pics[p].height>maxHeight) || (maxWidth>0 && pics[p].width>maxWidth)) { nwfnt.innerHTML=(linkReplace ? "<a href="+pics[p].src+" target='_blank'>"+repText+"</a" : repText); pics[p].parentNode.replaceChild(nwfnt,pics[p]); } } } break; } } }
// --> </script>
preview: wormocodes.proboards.com/index.cgi?board=codereqs&action=display&thread=211
|
|