Back to vBulletin Tips & Tricks

Auto resize images in showthread
by Jalo 13 Jun 2009

Hi all,

I was looking for an easy way to resize too large images and signatures in posts but most of the mods I looked at were just not simple enough. I didn't want any links or any other fancy stuff just smaller images.

This is how I did it:

Go to your control panel and open Styles & Templates, select your style and select Edit templates from the menu. In the left box scroll down to Show thread templates and double click. Double click on SHOWTHREAD.

Find:

Code:
</head>
Before add:

Code:
<script language="javascript" type="text/javascript"> 
<!-- 
  function resize_images() 
  { 
    for (i = 0; i < document.images.length; i++) 
    { 
      while ( !document.images[i].complete ) 
      { 
        break;
      } 
      if ( document.images[i].width > 480 ) 
      { 
        document.images[i].width = 480; 
      } 
    } 
  } 
//--> 
</script>
Find:

Code:
<body onload="$onload">
Replace with:

Code:
<body onLoad="resize_images()">
Safe and reload and check your forum to see if images are being resized.

You can change the '480' to your desired width.

This resizes all the images in showthread so if you have a 728x90 image banner or huge logo it also gets resized. Google 728x90 text ads and flash banners do not get resized.

I checked with Firefox, Safari and IE8.

If you do not want to remove the '$onload' from the code you can try:

Code:
<body onLoad="$onload; resize_images()">
Jalo

Similar Mods

Show Thread Enhancements Auto Resize large images in an IMG tag vBulletin 3.7 Add-ons
Auto Resize large images in an IMG tag vBulletin 3.5 Add-ons
Auto Resize Your Images 3.52 compliant vBulletin 3.5 Add-ons
Auto Resize Attachment Images... vBulletin 3.0 Beta Releases

vblts.ru supports vBulletin®, 2022-2024