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
  #132  
Old 07-15-2006, 11:55 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone using this code with vb 3.6 ?
Reply With Quote
  #133  
Old 07-16-2006, 01:09 AM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by A17roolz
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?
I had the first code and it worked in both IE,FF,opera and netscape.
Reply With Quote
  #134  
Old 07-16-2006, 01:13 AM
A17roolz's Avatar
A17roolz A17roolz is offline
 
Join Date: Jan 2006
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bhxtyrant
I had the first code and it worked in both IE,FF,opera and netscape.
Oh yeah, that code worked flawlessly, but what I'm trying to do is to have the image go to the maximum width it can without stretching if it causes the table to stretch. Putting 100% seems to make that work in FF, but not IE. To see what I mean, look at the below page in both IE and FF:

http://www.vgreality.com/testphp.php
Reply With Quote
  #135  
Old 07-16-2006, 04:37 AM
bhxtyrant bhxtyrant is offline
 
Join Date: Jun 2005
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah i know what you mean,I have been trying to do the same with the script found on a previous page but it seems the script will not accept sizes in % rather then pixels.I liked that script over the one you are looking at mainly due to the fact that it has the ability for a user to click the resized image to display the original image in a new window.It seems vB doesnt allow to many things in % in it's code not even the sizes for the text editor which would be really handy.
Reply With Quote
  #136  
Old 07-16-2006, 09:35 AM
A17roolz's Avatar
A17roolz A17roolz is offline
 
Join Date: Jan 2006
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by bhxtyrant
Yeah i know what you mean,I have been trying to do the same with the script found on a previous page but it seems the script will not accept sizes in % rather then pixels.I liked that script over the one you are looking at mainly due to the fact that it has the ability for a user to click the resized image to display the original image in a new window.It seems vB doesnt allow to many things in % in it's code not even the sizes for the text editor which would be really handy.
vB is not the problem here, what is the problem is IE, because that's what can't detect the coding. I'm not looking for a code with a clickable image if it gets too big because then you can't use the [url] BBCode with it, and that's really annoying. My philosophy is, if it's the width of the table, it's big enough for you to see anyways.
Reply With Quote
  #137  
Old 07-17-2006, 01:00 AM
TitanJeff's Avatar
TitanJeff TitanJeff is offline
 
Join Date: Jul 2002
Posts: 208
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I love the idea of this but am confused as to which of the codes I should be using.

I am running 3.5.1 and want to make sure these image sizes stay at 450 pixels wide. Thanks for any help.
Reply With Quote
  #138  
Old 07-27-2006, 04:22 AM
dodjer42's Avatar
dodjer42 dodjer42 is offline
 
Join Date: Jul 2006
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko
Lots of info here. If you're like me and don't want to add 30 lines of code to your img tags, do what I did.

replace this:

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

Code:
return '<img style="max-width:800px; width: expression(this.width > 800 ? 800: true);" src="' .  $link . '" border="0" alt="" />';
The code you want to replace is found in the function handle_bbcode_img_match() in class_bbcode.php. For me it was on line 1831.

This is fast and will work with either firefox or IE. It may even work with Opera, but I don't know.

I tried this and images no longer appear. Damn... I love the idea of only one line.
Reply With Quote
  #139  
Old 08-14-2006, 10:07 PM
SiMateoAko SiMateoAko is offline
 
Join Date: Apr 2006
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

NEW METHOD:

I can't believe I didn't think of this before.

Some of you may have editted your class_bbcode.php ( as per my instructions before ) to have it work correctly. I'd now recommend you don't do that and just add a few lines to your CSS file instead.

Add the following to your CSS:

Code:
IMG {
max-width: 700px;
width: expression(this.width > 700 ? 700: true);
}
Obviously change your values appropriately.

The benefits of doing it this way are hopefully obvious. No code changes are required, so upgrading won't be an issue.

IE is the real problem here b/c they are not totally CSS2 compliant. I believe it's been fixed with IE7, but the second statement (width: expression..) is just for people using old browsers.
Reply With Quote
  #140  
Old 08-29-2006, 11:26 AM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ That wont work because it even resized large image headers on sites that use forum width sized banners - its resizing banners on my site
Reply With Quote
  #141  
Old 08-30-2006, 12:55 AM
Ranger187 Ranger187 is offline
 
Join Date: Nov 2003
Posts: 921
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko
NEW METHOD:

I can't believe I didn't think of this before.

Some of you may have editted your class_bbcode.php ( as per my instructions before ) to have it work correctly. I'd now recommend you don't do that and just add a few lines to your CSS file instead.

Add the following to your CSS:

Code:
IMG {
max-width: 700px;
width: expression(this.width > 700 ? 700: true);
}
Obviously change your values appropriately.

The benefits of doing it this way are hopefully obvious. No code changes are required, so upgrading won't be an issue.

IE is the real problem here b/c they are not totally CSS2 compliant. I believe it's been fixed with IE7, but the second statement (width: expression..) is just for people using old browsers.
Where do we add this? What file, where? Can you elaborate?

Thanks.
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:03 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.04804 seconds
  • Memory Usage 2,332KB
  • 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
  • (4)bbcode_code
  • (4)bbcode_php
  • (5)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