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
  #102  
Old 03-08-2006, 01:51 AM
Blown Beauty Blown Beauty is offline
 
Join Date: Aug 2003
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Puntoboy
so if i use your code i won't have a problem?

Code:
	 /* Start hack Image RESIZE */  

		// Check to see if image exists
 		$link = str_replace(" " , "%20", $link);
 		$link = str_replace("&amp;" , "%26", $link);

		// Get host url name for fsockopen to see if server is reachable
		$img_host=str_replace('http://','',$link);
		$img_host=substr($img_host,0,strpos($img_host,'/'));

		// Check is server is reachable and timeout in 5 seconds if not
		if (@fclose(@fsockopen($img_host, 80, $fsockerr1, $fsockerr2, 5))) {
			// Check if image is on server
			if (@fclose(@fopen("$link", "rb"))) { 
				// Check image size and if oversize, change bbtag
				$img_width = getimagesize($link);
				if ($img_width[0] > 600) {
	 				$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="' . $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>';   
					}
				} else {
					return '<img src="' .  $link . '" border="0" alt="" />';
				}
			} else {
				// Image not found
				return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_link_broken'] . '</font></td></tr></table>';
			}
		} else {
			// Server is down
			return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_server_down'] . '</font></td></tr></table>';
		}
		
	/* End hack Image RESIZE */
Worked perfectly! Thanks!
Reply With Quote
  #103  
Old 03-11-2006, 02:20 PM
Zia's Avatar
Zia Zia is offline
 
Join Date: Dec 2005
Location: golpo.net
Posts: 931
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hello....
when we can accept an updated that wont touch sigs ?

and re-size works with IE,opera,firefox
Reply With Quote
  #104  
Old 03-14-2006, 04:38 PM
MotMann MotMann is offline
 
Join Date: Jan 2006
Location: Germany
Posts: 333
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by S@NL - BlackBik
OK guys,

Here is the last revision of my code. Finaly got it working:
Code:
	 /* Start hack Image RESIZE */  

		// Check to see if image exists
 		$link = str_replace(" " , "%20", $link);
 		$link = str_replace("&amp;" , "%26", $link);

		// Get host url name for fsockopen to see if server is reachable
		$img_host=str_replace('http://','',$link);
		$img_host=substr($img_host,0,strpos($img_host,'/'));

		// Check is server is reachable and timeout in 5 seconds if not
		if (@fclose(@fsockopen($img_host, 80, $fsockerr1, $fsockerr2, 5))) {
			// Check if image is on server
			if (@fclose(@fopen("$link", "rb"))) { 
				// Check image size and if oversize, change bbtag
				$img_width = getimagesize($link);
				if ($img_width[0] > 600) {
	 				$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="' . $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>';   
					}
				} else {
					return '<img src="' .  $link . '" border="0" alt="" />';
				}
			} else {
				// Image not found
				return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_link_broken'] . '</font></td></tr></table>';
			}
		} else {
			// Server is down
			return '<table border="1" cellpadding="2" id="image_found"><tr><td><FONT color="#FF0000">' . $vbphrase['image_server_down'] . '</font></td></tr></table>';
		}
		
	/* End hack Image RESIZE */ 
//	/* Original code:		return '<img src="' .  $link . '" border="0" alt="" />'; */
If you are gonna use this, be sure to add the three phrases.
What you mean? witch phrases?

And i have the problem, that the screens not in the same width and height... not in proportion. there are to high.

What shel i do?
Reply With Quote
  #105  
Old 03-26-2006, 08:11 PM
drewclark drewclark is offline
 
Join Date: Feb 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kildjean
I modified the info with the text you suggested and I got this error now:


Parse error: parse error, unexpected T_IF, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/zonaxbox/public_html/foros/includes/class_bbcode.php on line 1978
I'm getting the same error...
Reply With Quote
  #106  
Old 05-13-2006, 02:00 PM
chanthuyen chanthuyen is offline
 
Join Date: Sep 2005
Location: 9template.com
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by 3dsoft
The image resizes correctly but the layout is still broken in Opera 8.51

What are the template changes?
Try this : https://vborg.vbsupport.ru/showthread.php?t=115277

( Down load imageresize mod.zip)
Reply With Quote
  #107  
Old 05-18-2006, 04:47 PM
SiMateoAko SiMateoAko is offline
 
Join Date: Apr 2006
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #108  
Old 05-19-2006, 03:13 PM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I installed the mod and the resizing works perfectly, however I cant parse images as links anymore.
Reply With Quote
  #109  
Old 05-22-2006, 01:17 AM
Smiry Kin's's Avatar
Smiry Kin's Smiry Kin's is offline
 
Join Date: Dec 2005
Location: United Kingdom!
Posts: 954
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works perfect in 3.5.4
Reply With Quote
  #110  
Old 05-23-2006, 07:21 AM
Nathan2006's Avatar
Nathan2006 Nathan2006 is offline
 
Join Date: Feb 2006
Location: UK
Posts: 862
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you ggiersdorf

Just what I have been looking for

Install
Reply With Quote
  #111  
Old 05-23-2006, 11:52 AM
encryption's Avatar
encryption encryption is offline
 
Join Date: Sep 2005
Posts: 155
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so none of you are having the issue with parsing images as links ?
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 05:08 AM.


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.04642 seconds
  • Memory Usage 2,330KB
  • 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
  • (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