Back to vBulletin 3.0 Add-Ons

Automatic Image Resizing Javascript
Mod Version: 1.01, by Dorign

This modification is in the archives.
vB Version: 3.0.8 Rating: (0 vote - 0 average) Installs: 14
Released: 18 Aug 2005 Last Update: 18 Aug 2005 Downloads: 12
Not Supported Template Edits Code Changes  

This is my first mod. So.. God be with you all. :ninja:

Description: This is, to my knowledge, an image resize script that works any time an image is displayed in a post on your forum. It uses a simple javascript and the onload function found in many body tags. I have heard that there is some problem with the WYSIWYG, and though I'm not sure what that means, surely this modification corrects that.
This javascript resizes images when the following occurs:
- If an image appears over the limit you specify on any given post..
--- when in showthread mode (...showthread.php?t=####).
--- when in showpost mode (...showthread.php?p=####).
--- when in newreply mode while replying (topic review display).

Difficulty: Oughtta be fairly easy, just a few simple steps. Five minutes, if that.

Edits: Three PHP file edits, and one template edit.
root/showthread.php
root/includes/functions_showthread.php
root/includes/functions_editor.php
template:headinclude


Pros: Fast modification, doesn't slow down the forum display, resizes the images on every instance of the post, cached or not. Works in both IE and Mozilla browsers (fairly old and simple javascript, probably works with old browsers as well), and also on Apple's Safari.

Cons: The user must have java enabled or they will not see the code work, the page must be fully loaded before the resizing takes place, it will only resize images on posts (not private messages or other areas, though this could be added if needed).

Support: I have agreed to support this, as if it breaks your forum, I'd naturally want to help; that's not going to happen, though! Simple, easy code. If I can't support you, I'll break my back trying.

Warning: Again, this is my first mod, so I'm sorry if it's a bit crude. It works 100% for me, but I'm posting it in beta since.. well, since no one else has tested it; since I'm not really a coder, only advanced coders should install this until someone looks at it and says "It's good to go!" :nervous:

Version History:
8/18/05 - 1.00 - It's born and submitted as a beta. :ninja:
8/20/05 - 1.01 - No additions, but tested on cross platforms. Works! Released, no longer beta!

After I've had a few installs and 's from people, I'll request to have it made "official."
And without further delay, away we go.

------
START
------
STEP 1
------
In template headinclude
Scroll to bottom of file - Paste
HTML 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 > XREPLACEX ) 
      { 
        document.images[i].width = XREPLACEX; 
      } 
    } 
  } 
//--> 
</script>
Be sure to change both XREPLACEX instances to a width, such as "500."
------
STEP 2
------
In php file (root) showthread.php
Find
PHP Code:
// workaround for header redirect issue from forms with enctype in IE
// (use a scrollIntoView javascript call in the <body> onload event)
$onload ''
Replace with, or modify to
PHP Code:
// workaround for header redirect issue from forms with enctype in IE
// (use a scrollIntoView javascript call in the <body> onload event)
$onload 'resize_images();'
Still in php file (root) showthread.php
Find
PHP Code:
    if (!$QRrequireclick AND $WYSIWYG >= 1)
    {
        
$onload .= " editInit();";
        
    } 
Replace with, or modify to
PHP Code:
    if (!$QRrequireclick AND $WYSIWYG >= 1)
    {
        
$onload .= " resize_images(); editInit();";
        
    } 
Save file showthread.php, upload to root directory.
------
STEP 3
------
In php file (includes) functions_showthread.php
Find
PHP Code:
$onload " if (is_ie || is_moz) { fetch_object('currentPost').scrollIntoView(!is_moz); }"
Replace with, or modify to
PHP Code:
$onload "resize_images(); if (is_ie || is_moz) { fetch_object('currentPost').scrollIntoView(!is_moz); }"
Save file functions_showthread.php, upload to includes directory.
------
------
STEP 4
------
In php file (includes) functions_editor.php
Find
PHP Code:
        // set the onload event for the body tag
        
$onload ' onload="editInit();"'
Replace with, or modify to
PHP Code:
        // set the onload event for the body tag
        
$onload ' onload="resize_images(); editInit();"'
Still in php file (includes) functions_editor.php
Find
PHP Code:
$onload ' onload="editInit();"'
Replace with, or modify to
PHP Code:
$onload ' onload="resize_images(); editInit();"'
Save file functions_editor.php, upload to includes directory.
------
DONE
------
If you use it, please hit install! :P
------

If you have questions, please ask in this thread.
If you appreciate the modification, as a thanks, you could always link to my forum or try and get me more members. ^_^

http://www.forum-central.com/

For those of you who need screenshots, here you go. :nervous:

Download

This modification is archived and cannot be downloaded.

Supporters / CoAuthors

  • Dorign

Screenshots

   


vblts.ru supports vBulletin®, 2022-2024