Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Auto Resize Your Images 3.52 compliant Details »»
Auto Resize Your Images 3.52 compliant
Version: 1.00, by ggiersdorf ggiersdorf is offline
Developer Last Online: Aug 2012 Show Printable Version Email this Page

Version: 3.5.3 Rating:
Released: 12-27-2005 Last Update: Never Installs: 100
Template Edits
Code Changes  
No support by the author.

I was looking for some code that would allow an image over size x to be resized in IE, Firefox, and Opera. I tried all the variations out there without luck some would work in IE, some in Firefox, etc.. So I finally got a tweaked version of some old code that actually works flawless in IE, Firefox, and Opera. I have included it below, but It needs 1 final tweak that I'm hoping someone in the community can help with.

i am NOT taking credit for this hack, all I have done is tweak it to get it working for me..


This code has been updated as of 8:30pm with the clickable link built in now!

Step 1: Edit your class_bbcode.php file located in (root/includes)

find

PHP Code:
return '<img src="' .  $link '" border="0" alt="" />'
replace with the following.

PHP Code:
/* Start Image RESIZE */  

 
$navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower$_SERVER['HTTP_USER_AGENT'] ) : '';   
if (
stristr($navigator_user_agent"msie")) {   
    return 
'<a href="' .  $link '" target="_blank"><img src="' .  $link '" border="0" alt="" style="width: expression(this.width > 640 ? 480 : true);" /></a>';   
} else {   
    return 
'<a href="' .  $link '" target="_blank"><img src="' .  $link '" border="0" alt="" style="max-width: 730px;" /></a>';   
}    

/* End Image RESIZE */ 
you can play with the widths to get what you want working.

Show Your Support

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

Comments
  #122  
Old 06-12-2006, 04:35 AM
SiMateoAko SiMateoAko is offline
 
Join Date: Apr 2006
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by jags2ooo
SiMateoAko AWESOME IT WORKS PERFECT!!!!!!!!! i just opened up a new forums 1 hour ago and of course some dude had to post a image that was so FREaking big and fked up the boards so i cam ehere ran a search and bam your fix owns THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11

I recommend Simateoako's version of this mod his is posted at post number #106 its nice and short only 1 line
There is a small problem with this and I had to remove it. It seems that when someone quotes a message with images in it they do not always parse correctly for the text editor.

I'm going to have to look into it a bit more.
Reply With Quote
  #123  
Old 06-14-2006, 03:01 PM
SiMateoAko SiMateoAko is offline
 
Join Date: Apr 2006
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko
There is a small problem with this and I had to remove it. It seems that when someone quotes a message with images in it they do not always parse correctly for the text editor.

I'm going to have to look into it a bit more.
I just replaced the code as follows and it appears to be working correctly. i'll give an explanation below for people to understand.

replace this line in your class_bbcode.php file:
Code:
return '<img src="' .  $link . '" border="0" alt="" />';
With this line:

Code:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' .  $link . '" border="0" alt="" >';
A style attribute in firefox is "max-width," and it does everything we want it to do. "max-height" is also a style attribute.

IE, in it's infinite wisdom, decided to not include this style attribute. As a result we have to use a java expression to resize the image.

In the past there were issues if I quoted a post with an image in it, but it appears to be better now that the two style expressions are seperate.

With any luck IE will add the "max-width" and "max-height" expression for future versions of IE.
Reply With Quote
  #124  
Old 06-14-2006, 06:45 PM
nymyth nymyth is offline
 
Join Date: Jun 2002
Location: New York
Posts: 367
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^Works great mate...thanks...

Peace
Reply With Quote
  #125  
Old 06-19-2006, 09:01 PM
tormento tormento is offline
 
Join Date: Jun 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

work great on mine

forums
Reply With Quote
  #126  
Old 06-19-2006, 09:03 PM
tormento tormento is offline
 
Join Date: Jun 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ot
for the attach,someone has an idea for me?
Reply With Quote
  #127  
Old 06-22-2006, 04:56 PM
epicbear epicbear is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not sure if something is seeing is related to this hack or not but in either case, I could use a little help.

I'm seeing some weird behavior, ONLY in IE. The image in question is being resized properly but the page is still going wide...even though the image isn't even wide enough to caus that to begin with!

Here's what I've discovered. If I paste the page source into Dreamweaver and save it and preview it in IE, the page is still strtched wide, inspite of all the missing css and images...so I start debugging and find the fulcrum upon which this behavior tilts.

There is an image:

http://i68.photobucket.com/albums/i1...ccident015.jpg

if I edit the URL so that the host is www and not i68, the horizontal scrolling issue disappears.

Can anyone see any reason for this either due to this hack or IE itself?
Reply With Quote
  #128  
Old 06-30-2006, 05:31 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

none of the codes work for vBulletin 3.6 Beta 3. (at least if you edit the message)

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

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

        return 
'<img src="' .  $link '" border="0" alt="" />';
    } 
Anyone has vb 3.6 compatible version of the image resizing code?
Reply With Quote
  #129  
Old 07-02-2006, 01:42 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some invalid html image code shows up if you edit the message...
Reply With Quote
  #130  
Old 07-13-2006, 09:08 PM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko
I just replaced the code as follows and it appears to be working correctly. i'll give an explanation below for people to understand.

replace this line in your class_bbcode.php file:
Code:
return '<img src="' .  $link . '" border="0" alt="" />';
With this line:

Code:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' .  $link . '" border="0" alt="" >';
A style attribute in firefox is "max-width," and it does everything we want it to do. "max-height" is also a style attribute.

IE, in it's infinite wisdom, decided to not include this style attribute. As a result we have to use a java expression to resize the image.

In the past there were issues if I quoted a post with an image in it, but it appears to be better now that the two style expressions are seperate.

With any luck IE will add the "max-width" and "max-height" expression for future versions of IE.
I added this to my forum and it works great,I was wondering if i might make a request.Can someone add a code to this current code that gives the option to make the resized image clickable to view the full image in a new window?

I tryed this hack before https://vborg.vbsupport.ru/showthrea...t=99286&page=7 which does have that option but i had loads of trouble getting it to work.Sometimes it would work others it would not especially in IE6.Thanks also note im using VB 3.5.4 if thats of any relivence.
Reply With Quote
  #131  
Old 07-15-2006, 06:29 PM
A17roolz's Avatar
A17roolz A17roolz is offline
 
Join Date: Jan 2006
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko
I just replaced the code as follows and it appears to be working correctly. i'll give an explanation below for people to understand.

replace this line in your class_bbcode.php file:
Code:
return '<img src="' .  $link . '" border="0" alt="" />';
With this line:

Code:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' .  $link . '" border="0" alt="" >';
A style attribute in firefox is "max-width," and it does everything we want it to do. "max-height" is also a style attribute.

IE, in it's infinite wisdom, decided to not include this style attribute. As a result we have to use a java expression to resize the image.

In the past there were issues if I quoted a post with an image in it, but it appears to be better now that the two style expressions are seperate.

With any luck IE will add the "max-width" and "max-height" expression for future versions of IE.
Awesome code! Although I have a problem...

See, the reason I needed an image resizer was mostly for my news fetch (click here to see what I mean). I'm perfectly fine with everything, except the bbs main body is actually larger than the news fetch body, and it poses a problem with signatures. I'm ok with main body images being resized, but is there a way to keep signatures unaffected by image resizes? Or, even better, make it so that the signature images have a different resize limit?

EDIT: Nevermind, I found out how to make the image stay at it's normal size unless it stretches the page. Just replace this:

PHP Code:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' .  $link '" border="0" alt="" >'
With this:

PHP Code:
return '<img style="max-width:100%;" style= "width: expression(this.width > 100% ? 100%: true);" src="' .  $link '" border="0" alt="" >'
EDIT 2: Hmmm, this code only seems to work in Firefox (dunno about Opera). Anyone have anyideas as to how I can get it to work in IE?
Reply With Quote
Reply


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 06:14 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05239 seconds
  • Memory Usage 2,338KB
  • 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
  • (6)bbcode_code
  • (5)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
  • (1)pagenav_pagelinkrel
  • (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