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
  #112  
Old 05-23-2006, 08:21 PM
skooby skooby is offline
 
Join Date: May 2006
Posts: 77
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm having a problem with my news portal in my CMPS.

When I added the code, it resizes images in the posts. But when the Module tries to grab the resized image to post it on the homepage, it won't display the image if it is over the size that I set for it.

I used S@NL - BlackBik code in post# 47

I basically want the news module to grab the information in a selected forum on my site which includes an image in each post, and post that image on the main page in the news module, but the images need to be resized to fit the page correctly. If the image is over the set width of 400, it won't resize and display, it just doesn't display it period. It does resize it though if I go to the actual post. I need it to resize the image so it is displayed correctly in the news module of my CMPS on the mainpage.

Any ideas how to fix this?
Reply With Quote
  #113  
Old 05-24-2006, 05:18 PM
epicbear epicbear is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I installed this and it works great on the images but the whole problem I was having hasn't gone away.

On this page,

http://forums.epicski.com/showthread.php?t=33971

the offending image was in post #6. As you can see, it's resized. If you're viewing the page with Firefox...it looks fine. If you're viewing the page in IE...the tables still blow out really wide and require much horizontal scrolling.

Any ideas what's going on here?
Reply With Quote
  #114  
Old 05-24-2006, 05:49 PM
epicbear epicbear is offline
 
Join Date: May 2006
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by epicbear
Ok, I installed this and it works great on the images but the whole problem I was having hasn't gone away.

On this page,

http://forums.epicski.com/showthread.php?t=33971

the offending image was in post #6. As you can see, it's resized. If you're viewing the page with Firefox...it looks fine. If you're viewing the page in IE...the tables still blow out really wide and require much horizontal scrolling.

Any ideas what's going on here?
Nevermind...
Reply With Quote
  #115  
Old 05-24-2006, 06:17 PM
bada_bing's Avatar
bada_bing bada_bing is offline
 
Join Date: Feb 2004
Location: Michigan
Posts: 1,698
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed and working good so far on vb 3.5.3

Thank You
Reply With Quote
  #116  
Old 05-26-2006, 04:11 PM
blacklancer's Avatar
blacklancer blacklancer is offline
 
Join Date: Jan 2006
Location: so cal
Posts: 84
Благодарил(а): 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.
thats where its at! perfect! doesn't mess with the sigs at all. thanks so much!

:banana::banana::banana:
Reply With Quote
  #117  
Old 05-28-2006, 02:06 AM
Neurotoxin Neurotoxin is offline
 
Join Date: Jan 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome mod, works perfect!
Reply With Quote
  #118  
Old 05-28-2006, 08:07 PM
Bulent Tekcan Bulent Tekcan is offline
 
Join Date: Oct 2003
Location: TURKEY - Istanbul
Posts: 437
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ggiersdorf
The problem I am running into now is basically Signatures are used with the IMG tag this mod changes anything that has the IMG tag.

We need to re-write the $signature to use an alternate img tag like [SIG] [SIG] or somehow have the field for signatures remove the script above and use the default one from Vb. Basically trick it in signatures to use original vb code.

PHP Code:
 return '<img src="' $link '" border="0" alt="" />'
anyone want to help with this let me know I have some updated code than the above that works better but Im holding off posting it till were done here..
Same problem here....this hack removed :tired:
Reply With Quote
  #119  
Old 05-29-2006, 05:49 PM
jags2ooo jags2ooo is offline
 
Join Date: Jan 2002
Location: New York
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #120  
Old 06-03-2006, 04:39 PM
Djamil Djamil is offline
 
Join Date: Mar 2006
Location: Germany
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by S@NL - BlackBik
Find:
Code:
return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 600 ? 600 : true);" /></a>';   
} else {   
return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 600px;" /></a>';   
}
and replace by:
Code:
return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 600 ? 600 : true);" /><br><br>' . $vbphrase['click_for_larger_image'] . '</a>';   
} else {   
return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 600px;" /><br><br>' . $vbphrase['click_for_larger_image'] . '</a>';   
}
I can't manage to make the phrases work.

The line breaks are there but the phrase text is missing. I triple-checked the phrase names, they are correct. Even the version posted in https://vborg.vbsupport.ru/showthread.php?p=52 doesn't show the phrase in the alt-tag. Any hints ?

Djamil
Reply With Quote
  #121  
Old 06-04-2006, 12:53 PM
Djamil Djamil is offline
 
Join Date: Mar 2006
Location: Germany
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found out myself. There's important information missing in Post 52. If you defined the phrases as global phrases (which seemed the appropriate way to me since there was no specific phrasetype mentioned to define them in) and want the phrases to show up, you must do the following:

FIND

Code:
function handle_bbcode_img_match($link)
	{
ADD AFTER

Code:
global $vbphrase;
Then the phrases will show up.

For further information please consult this chapter of the vB manual

Djamil
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 04:04 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.05255 seconds
  • Memory Usage 2,331KB
  • 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
  • (3)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