Post by - TuGs on Mar 20, 2013 22:14:36 GMT -8
Is there a way to resize a image by width and height by percent similar to this old global footer code? by Todge
It used to resize any image in posts and signatures. Like So:
after this SS was taken i removed the code:
This image is reduced by '+newWidth+'%, click it to view full size.
so it would just re-size with no notification so it wouldn't also be in the signatures.
<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>
In my current V5 the image size on my forum is perfect in post's. (i think it automatically re-sizes the images here)
but the problem i see is if the signature is too wide it cuts it off. Like So
i dont want the image squished one way to fit. so i need a code/plugin/template mod that resizes it by %
thanks for your time.
i can only hope for a solution!