vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Auto Resize Your Images 3.52 compliant (https://vborg.vbsupport.ru/showthread.php?t=103915)

SiMateoAko 06-12-2006 04:35 AM

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 :D

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.

SiMateoAko 06-14-2006 03:01 PM

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.

nymyth 06-14-2006 06:45 PM

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

Peace

tormento 06-19-2006 09:01 PM

work great on mine

forums

tormento 06-19-2006 09:03 PM

ot
for the attach,someone has an idea for me?

epicbear 06-22-2006 04:56 PM

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?

NeutralizeR 06-30-2006 05:31 PM

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?

NeutralizeR 07-02-2006 01:42 PM

Some invalid html image code shows up if you edit the message...

bhxtyrant 07-13-2006 09:08 PM

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.

A17roolz 07-15-2006 06:29 PM

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?

NeutralizeR 07-15-2006 11:55 PM

Anyone using this code with vb 3.6 ?

bhxtyrant 07-16-2006 01:09 AM

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.

A17roolz 07-16-2006 01:13 AM

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

bhxtyrant 07-16-2006 04:37 AM

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.

A17roolz 07-16-2006 09:35 AM

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.

TitanJeff 07-17-2006 01:00 AM

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.

dodjer42 07-27-2006 04:22 AM

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.

SiMateoAko 08-14-2006 10:07 PM

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.

encryption 08-29-2006 11:26 AM

^^ That wont work because it even resized large image headers on sites that use forum width sized banners - its resizing banners on my site

Ranger187 08-30-2006 12:55 AM

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.

Aaron RV 09-06-2006 03:17 AM

ok for vb 3.6?

Traxdata 09-07-2006 03:52 PM

Yes. Works fine with vb 3.6.

GNDI 09-20-2006 12:10 PM

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.

by doing it this way you loose the link to the ral fullsize image :(

NeutralizeR 09-26-2006 10:15 PM

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.

PersianImmortal 09-29-2006 03:36 AM

Very useful, neutralizer thanks - this is by far the easiest way to do this.

I personally set both max width and max height in the CSS definition, as extremely 'tall' images can be annoying too, i.e. I use this CSS code:

HTML Code:

.resize
{
max-width: 500px;
max-height: 400px;
width: expression(this.width > 500 ? 500: true);
height: expression(this.height > 400 ? 400: true);
}

This is on a VB 3.6.0 forum. The one thing I would like though is a way of making this resized image clickable so you can view the larger image with a click - anyone know how to easily add this function via CSS (even if it has to call a function in headinclude)?

/EDIT: Nevermind, I wound up modifying and using the code here and it works a treat for me :)

smsmasters 10-07-2006 09:01 PM

Quote:

Originally Posted by NeutralizeR
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.

Excellent! :)

manutdvn 10-08-2006 04:25 PM

Quote:

Originally Posted by BluPhoenix
change:
Code:

/* Start Image RESIZE */ 

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

/* End Image RESIZE */

to:

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 */

That'll make it clickable.. but what does the javascript addition do? from what I see your just using css no need for the javascript?

Thank you. It works great with IE 7.0 and Firefox. Click install. I am current with VBB 3.5.4

RFViet 10-10-2006 04:52 PM

I'm confused !! which code is used for vB3.5.5 ??

smsmasters 10-10-2006 08:58 PM

This works great but how do I stop the images in signatures from being resized too?

Thanks

Quote:

Originally Posted by NeutralizeR
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.


Aaron RV 11-20-2006 07:35 AM

in vb 3.6.3 not work.
when I can change the code?

thank's.

kal-L 02-06-2007 03:17 PM

Quote:

Originally Posted by SiMateoAko (Post 980065)
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:

taydu 02-09-2007 11:24 PM

Quote:

Originally Posted by NeutralizeR (Post 1084205)
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 :(

Traxdata 12-18-2007 12:49 PM

lol. still working even on 3.7.0. beta2 :)

not sure why it is not default in vbulletin???

phpnewbie 12-20-2007 01:48 PM

Quote:

Originally Posted by A-handreas (Post 861739)
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 :D
this tut so cool, have no "product" & no javascript ^^

thank you very much

phpnewbie 12-22-2007 09:58 AM

problem:
if image width is smaller "max-width", it still makes a "link" on that image.

csmcsm 01-19-2008 03:20 PM

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 :p

also working on getting lightbox2 working with it :)


ANYONE using My code pre 12:44 20th january 2008 CET please update your code!


All times are GMT. The time now is 05:58 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01611 seconds
  • Memory Usage 1,908KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (15)bbcode_code_printable
  • (5)bbcode_html_printable
  • (14)bbcode_php_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (36)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete