Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases

Reply
 
Thread Tools
Auto resize Huge images for [IMG] bbcode Details »»
Auto resize Huge images for [IMG] bbcode
Version: 1.00, by 007pig 007pig is offline
Developer Last Online: Jan 2011 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 08-23-2004 Last Update: Never Installs: 44
 
No support by the author.

I find lots of people are looking for [IMG] hack. So i share mine now.

The hack modifies only a few lines and the images are resized automaticly by javascript.

Open functions_bbcodeparse.php

Search:
PHP Code:
function handle_bbcode_img_match($link)
{
    
$link strip_smilies(str_replace('\\"''"'$link));

    
// remove double spaces -- fixes issues with wordwrap
    
$link str_replace('  '''$link);

    return 
'<img src="' .  $link '" border="0" alt="" />';

Replace with:
PHP Code:
function handle_bbcode_img_match($link)
{
    global 
$vboptions;
    
    
$link strip_smilies(str_replace('\\"''"'$link));

    
// remove double spaces -- fixes issues with wordwrap
    
$link str_replace('  '''$link);

    if (
$vboptions['legacypostbit'])
    {
        return 
'<a href=' $link ' target="_blank"><img src="' $link '" onload="if(this.width>screen.width-255) {this.width=screen.width-255;this.alt=\'Full View\';}" onmouseover="if(this.alt) this.style.cursor=\'hand\';" border="0"></a>';
    }
    else
    {
        return 
'<a href=' $link ' target="_blank"><img src="' $link '" onload="if(this.width>screen.width-80) {this.width=screen.width-80;this.alt=\'Full View\';}" onmouseover="if(this.alt) this.style.cursor=\'hand\';" border="0"></a>';
    }

All done. Enjoy!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #32  
Old 12-13-2004, 12:56 AM
Bison's Avatar
Bison Bison is offline
 
Join Date: Jun 2002
Location: Virginia Beach, Virginia
Posts: 522
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This one works great!!!

https://vborg.vbsupport.ru/showthread.php?t=67743
Reply With Quote
  #33  
Old 02-20-2005, 08:05 PM
msimplay's Avatar
msimplay msimplay is offline
 
Join Date: Aug 2002
Location: UK
Posts: 1,059
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I like this hack a lot but it causes funny things when used with

https://vborg.vbsupport.ru/showthread.php?t=73040 the geek gallery popup hack

any chance to make it work with it ?
Reply With Quote
  #34  
Old 04-01-2005, 03:24 PM
hollyboy's Avatar
hollyboy hollyboy is offline
 
Join Date: Mar 2004
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what's the difference with this hack?
https://vborg.vbsupport.ru/showthrea...t=image+resize
Reply With Quote
  #35  
Old 04-05-2005, 11:35 PM
Howdy Howdy is offline
 
Join Date: Feb 2005
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome hack, thanks!
Reply With Quote
  #36  
Old 04-07-2005, 11:55 AM
Onkel_Tom's Avatar
Onkel_Tom Onkel_Tom is offline
 
Join Date: Mar 2002
Location: Stuttgart- Germany
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

clicked install !
works fine, thanks
Reply With Quote
  #37  
Old 04-07-2005, 08:42 PM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by hollyboy
what's the difference with this hack?
https://vborg.vbsupport.ru/showthrea...t=image+resize
This one resizes on the client using JavaScript appended to each image tag, whereas the other one (the one you quoted) uses server fetch requests to get the image and check the size and adjusts the tag as applicable.

This hack will still load pages slowly for the client, but the layout will be fine. It will be fast for the server, slow for the browser.

That hack will still load pages slowly for the client, and the layout will be fine. But it will be slow for the server, fast for the browser.

May I make a suggestion about this hack though? Perhaps another method?

Instead of adding JavaScript to every IMG tag within every post, and firing that many onloads... why not just add javascript to your headinclude template that parses all images onload?

Example... Put this in your headinclude... and don't bother hacking any vBulletin files:
HTML Code:
<script type="text/javascript">
function resizeImages() {
  if (document.images) {
    var mw = 800;
    var mh = 800;
    for (var ii = 0; ii < document.images.length; ii++) {
      var i = document.images[ii];
      var iw = i.width;
      var ih = i.height;
      if (ih > iw && ih > mh) {
        i.style.height = mh + 'px';
      } else if (iw > mw) {
        i.style.width = mw + 'px';
      }
    }
  }
}
if (window.addEventListener) {
  window.addEventListener('load', resizeImages, false);
} else if (window.attachEvent) {
  window.attachEvent('onload', resizeImages);
} else {
  window.onload = resizeImages;
}
//-->
</script>
mw = maximum width in pixels.
mh = maximum height in pixels.

I've got mine set to 800 x 800, but you could put what you want in there.

Any img on the page will be resized to fit that area.

Of course, the end user still has to download them, but this resolves the problem with the script part going through to edits and quotes, and is also an easier install.

You don't have to use this version, but it's simpler methinks.
Reply With Quote
  #38  
Old 04-11-2005, 11:11 PM
Onkel_Tom's Avatar
Onkel_Tom Onkel_Tom is offline
 
Join Date: Mar 2002
Location: Stuttgart- Germany
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
This one resizes on the client using JavaScript appended to each image tag, whereas the other one (the one you quoted) uses server fetch requests to get the image and check the size and adjusts the tag as applicable.

This hack will still load pages slowly for the client, but the layout will be fine. It will be fast for the server, slow for the browser.

That hack will still load pages slowly for the client, and the layout will be fine. But it will be slow for the server, fast for the browser.

May I make a suggestion about this hack though? Perhaps another method?

Instead of adding JavaScript to every IMG tag within every post, and firing that many onloads... why not just add javascript to your headinclude template that parses all images onload?

Example... Put this in your headinclude... and don't bother hacking any vBulletin files:
HTML Code:
<script type="text/javascript">
function resizeImages() {
  if (document.images) {
    var mw = 800;
    var mh = 800;
    for (var ii = 0; ii < document.images.length; ii++) {
      var i = document.images[ii];
      var iw = i.width;
      var ih = i.height;
      if (ih > iw && ih > mh) {
        i.style.height = mh + 'px';
      } else if (iw > mw) {
        i.style.width = mw + 'px';
      }
    }
  }
}
if (window.addEventListener) {
  window.addEventListener('load', resizeImages, false);
} else if (window.attachEvent) {
  window.attachEvent('onload', resizeImages);
} else {
  window.onload = resizeImages;
}
//-->
</script>
mw = maximum width in pixels.
mh = maximum height in pixels.

I've got mine set to 800 x 800, but you could put what you want in there.

Any img on the page will be resized to fit that area.

Of course, the end user still has to download them, but this resolves the problem with the script part going through to edits and quotes, and is also an easier install.

You don't have to use this version, but it's simpler methinks.
This version works better for me and doesn't have problem with the WYSIWYG Editor.
Is there a chance to add a link in the resized picture to open the original version and size in a new window?
Reply With Quote
  #39  
Old 04-12-2005, 02:59 AM
ChrisLM2001 ChrisLM2001 is offline
 
Join Date: May 2003
Posts: 126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by buro9
I've got mine set to 800 x 800, but you could put what you want in there.

Any img on the page will be resized to fit that area.

Of course, the end user still has to download them, but this resolves the problem with the script part going through to edits and quotes, and is also an easier install.

You don't have to use this version, but it's simpler methinks.
Just tried it out and it works as intended in the WYSIWYG text editor (edited a post and pasted the image code in, and it works on those as well). Fast too.

Ahhhhhh, finally no more table breaks.

Chris
Reply With Quote
  #40  
Old 04-14-2005, 08:56 AM
buro9 buro9 is offline
 
Join Date: Feb 2002
Location: London, UK
Posts: 585
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Onkel_Tom
This version works better for me and doesn't have problem with the WYSIWYG Editor.
Is there a chance to add a link in the resized picture to open the original version and size in a new window?
Yup, that's not too hard... but you know what would happen

You either:
1) Add javascript onclick to each image... which breaks the WYSIWYG again.
or
2) You wrap an A element around the image, but it's messy and might not work cross browser.

I can look into it though, I have some old DOM tree javascript lying around and I might already have a method to convert a child element to a grandchild by creating a new parent.

If I do have that and it doesn't affect image placement in the post I'll show an example of that too.
Reply With Quote
  #41  
Old 05-19-2005, 11:05 AM
artonex artonex is offline
 
Join Date: Mar 2005
Location: UK
Posts: 121
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hey i had cinq install this hack on http://www.talkweed.com/forums/ but its not working, do you know why ?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04707 seconds
  • Memory Usage 2,314KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_html
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete