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
  #152  
Old 02-06-2007, 03:17 PM
kal-L kal-L is offline
 
Join Date: Dec 2006
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SiMateoAko View Post
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.
Not only did this work for 3.6.4 but it worked fast and for IE,Firefox and Indeed Opera.:up:
Reply With Quote
  #153  
Old 02-09-2007, 11:24 PM
taydu taydu is offline
 
Join Date: Oct 2006
Posts: 103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by NeutralizeR View Post
I've found an alternative solution (I'm running a vBulletin 3.6.1 board)

Open your /forum/includes/class_bbcode.php file:

On line 1879, replace:
PHP Code:
return '<img src="' .  $link '" border="0" alt="" />'
with:
PHP Code:
return '<img class="resize" src="' .  $link '" border="0" alt="" />'
Open your Style Manager > Main CSS > Additional CSS Definitions and add this code at the bottom:
HTML Code:
.resize {max-width: 728px; width: expression(this.width > 728 ? 728: true);}
Save.

Tested both in IE7 RC1 & Firefox 1.5.0.7

Resized image will keep it's link if it has any.

Demo:
http://www.msxlabs.org/forum/dogadan...tml#post224010

Actual image width is 1024 pixels (resized to 728px) and the thumbnail keeps the link.
darn it, not working 3.6.4 for me
Reply With Quote
  #154  
Old 12-18-2007, 12:49 PM
Traxdata Traxdata is offline
 
Join Date: Jul 2004
Posts: 128
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

lol. still working even on 3.7.0. beta2

not sure why it is not default in vbulletin???
Reply With Quote
  #155  
Old 12-20-2007, 01:48 PM
phpnewbie phpnewbie is offline
 
Join Date: Oct 2003
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by A-handreas View Post
Hello guys,

I've tried your hack, it works perfect in IE but it didn't work with Firefox 1.5 :disappointed: Any idea ?

best regards
Andreas
i'm using FF 2.0.11 and it still works normally
this tut so cool, have no "product" & no javascript ^^

thank you very much
Reply With Quote
  #156  
Old 12-22-2007, 09:58 AM
phpnewbie phpnewbie is offline
 
Join Date: Oct 2003
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

problem:
if image width is smaller "max-width", it still makes a "link" on that image.
Reply With Quote
  #157  
Old 01-19-2008, 03:20 PM
csmcsm csmcsm is offline
 
Join Date: Jan 2008
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Made a slight tweak, to remove the link if the image was smaller than or 730px wide:
PHP Code:
/* Start Image RESIZE */  

         
$navigator_user_agent = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? strtolower$_SERVER['HTTP_USER_AGENT'] ) : ''
         if (@
fopen($link"r"))
         {  
         list(
$width$height$type$attr) = getimagesize($link);
         }
        if (
stristr($navigator_user_agent"msie")) {
            
$image_size_link '
            <img src="' 
.  $link '" border="0" rel="lightbox" title="'.$link.'" alt="" style="width: expression(this.width > 640 ? 480 : true);" />';   
                } 
                else {   
            
$image_size_link '<img src="' .  $link '" border="0" rel="lightbox" title="'.$link.'" alt="" style="max-width: 730px;" />';
        }
        if (@
fopen($link"r"))
         { 
            if(
$width <= 730)
            {
                
$image_size '<a href="' .  $link '" target="_blank">'.$image_size_link.'</a>';
            }
            else 
            {
            
$image_size '
                
                <table cellpadding="0" cellspacing="0" border="1">
                    <tr><td style="background-color:#000000;color:#FFFFFF;">
                <a href="' 
.  $link '" target="_blank" style="color:#FFFFFF;text-decoration:none;">Click to enlarge image</a>
                    </td></tr>
                    <tr><td><a href="' 
.  $link '" target="_blank">' $image_size_link '</a></td></tr>
                    <tr><td style="background-color:#000000;color:#FFFFFF;">
                <a href="' 
.  $link '" target="_blank" style="color:#FFFFFF;text-decoration:none;">Click to enlarge image</a>
                    </td></tr>
                </table>
                
            '
;   
            }
         
        return 
$image_size;
         }
/* End Image RESIZE */ 
requires GD though

also working on getting lightbox2 working with it


ANYONE using My code pre 12:44 20th january 2008 CET please update your code!
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 11:12 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.04340 seconds
  • Memory Usage 2,305KB
  • Queries Executed 23 (?)
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_code
  • (1)bbcode_html
  • (5)bbcode_php
  • (3)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
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (6)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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