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)

ggiersdorf 12-27-2005 10:00 PM

Auto Resize Your Images 3.52 compliant
 
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.

BluPhoenix 12-28-2005 10:41 PM

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?

ggiersdorf 12-28-2005 11:18 PM

Actually you do not need the Java, it was a left over routine from an older version.
Thank you for you addition to this hack.. I truley believe this is the best auto-resize for vbulletin 3.5+

Now we need to add a Click here to enlarge text over the image!

I have tested and modified the code at the top.. any additions or modifications to make this better please let us know!

Otherwise enjoy!

Example is at http://www.gamereports.net/showthread.php?p=167#post167

apfparadise 12-29-2005 12:16 AM

Not resizing in Opera. IE looks great.

joelabq 12-29-2005 03:15 AM

Here's a modified version with "Click to enlarge image" text on top/bottom...Just a quick edit...

PHP Code:

/* Start Image RESIZE */  

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


apfparadise 12-29-2005 04:15 AM

This is weird, but my /includes/class_bbcode.php does not have this line at all, or even parts of it in any shape or form:

Code:

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

Aaron RV 12-29-2005 04:26 AM

Work but if I quote a message with the image the writing it appears "click to..." repeated.

joelabq 12-29-2005 05:38 AM

Quote:

Originally Posted by apfparadise
This is weird, but my /includes/class_bbcode.php does not have this line at all, or even parts of it in any shape or form:

Code:

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

I had to take out some of the leading and trailing text to find it for some reason myself...

Try searching with the return ' part

I didn't try that quoting thing... I'm gonna go check that now.

Joel

furst 12-29-2005 06:03 AM

This looks pretty good and I'll most likely install it tomorrow.

..mind if I ask where you got a working link hider for 3.5.2?

Quote:

[Link only for Registered Users. Please sign up and help us grow!]

sensimilla 12-29-2005 08:05 AM

Thats the best one from all I tried before! thanks

Snakey 12-29-2005 10:05 AM

Nice hack, but couldn't it be possible to change this into a plugin? Using the hook bbcode_parse or something?

Ghanem 12-29-2005 10:16 PM

Hi,

Thanks for the hack..

isn't it suppose to resize large images only..
as if I use it, every img in the post becomes clickable, and if I use joelabq addition, every ims wil be contained in a box with click to enlarge :ermm: ..

Regards

sgtmaj 12-30-2005 12:37 AM

does this work also when you use the Manage Attachments feature ??

sensimilla 12-30-2005 06:19 AM

@sgtmaj its not for attachments its for hotlinked images with [ img ] tag

sgtmaj 12-30-2005 06:49 PM

Quote:

Originally Posted by sensimilla
@sgtmaj its not for attachments its for hotlinked images with [ img ] tag

ok thats what I thought but figured I best check. Thanx for the reply....wouldn't happen to know if they got one for the attachments do ya?

da prez 12-30-2005 08:49 PM

ignore, sorry.

DF-inside 12-31-2005 09:20 AM

This MOD will also make images smaller then the size I have filled in linkable.
And so when I have images from the VBB board showing up at my main site (non-vbb) and I got an border arround the images telling them to click to enlare, all the images will show that.

A-handreas 01-01-2006 12:50 PM

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

cbr929rrerion 01-02-2006 04:36 AM

clicks install.. or something like that.. thanks guys...

midnightwalker 01-05-2006 03:50 PM

it seems didnn't work in case you have attached your image and make it hotlink likes:

[img ] http://blablabla/attachment.php...blabla [/ img]

anyone can solve this?

TF|Scorpion 01-06-2006 11:30 PM

Does this work on v. 3.5.3?

ggiersdorf 01-07-2006 09:48 AM

Quote:

Originally Posted by TF|Scorpion
Does this work on v. 3.5.3?

Yes it should work fine on 3.53

ggiersdorf 01-07-2006 09:50 AM

Quote:

Originally Posted by A-handreas
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

works fine on my Firefox, IE and OPERA try clearing your cache and try it!?

Emil 01-07-2006 10:31 PM

Anyway to make this work with Opera browsers?

And there's a problem with imageshack. When you post auto generated thumbnails from imageshack, they stop working. When you click on them they just open the thumbnail instead of the real size image.

I'm talking about these kind of imageshacks thumbnails:

http://img280.imageshack.us/img280/8...x0014ck.th.jpg

When you click on this one it'll open a big image in a new window. But after I added this resize hack, those thumbnails stopped working. They just open the thumbnail again. Any way to fix this?

S@NL - BlackBik 01-09-2006 06:19 PM

Installed and it seemes to work :)

S@NL - BlackBik 01-09-2006 06:59 PM

Since we run a board that supports two languages, i've added a little tweak and made the alt-tag a phrase. Use if you will :)
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="' . $vbphrase['click_for_larger_image'] . '" style="width: expression(this.width > 480 ? 480 : true);" /></a>'; 
                } else { 
                    return '<a href="' .  $link . '" target="_blank"><img src="' .  $link . '" border="0" alt="' . $vbphrase['click_for_larger_image'] . '" style="max-width: 480px;" /></a>'; 
                }   

        /* End Image RESIZE */

To make this work you have to add the following to the function:

find:
function handle_bbcode_img_match($link)
{

and add right under:

global $vbphrase;

Ow, and don't forget to add this phrase offcourse

Enjoy :)

Codeman05 01-09-2006 09:28 PM

Quote:

Originally Posted by DF-inside
This MOD will also make images smaller then the size I have filled in linkable.
And so when I have images from the VBB board showing up at my main site (non-vbb) and I got an border arround the images telling them to click to enlare, all the images will show that.

I get the same, anyway to get around this?

apfparadise 01-09-2006 10:07 PM

I see people installing it and saying it works in browsers other than IE. There is no way it does. I looked at the creator's site on the three browsers and it did not work on anything other than IE. I just installed on my board and took it off, as it DOES NOT work in Opera or Firefox.

Can someone fix it? I really kind of need it but only if it's cross-browser. it worked so well in 3.0.

Also, I have $20 Paypal for anyone who can integrate this, correctly, with the "click on it to see a larger image" and the ability to hide IMG images from Unregistered users. Both were available on 3.0 so it's a straight port.

Codeman05 01-09-2006 10:32 PM

I just installed it. I can't speak for the creators site, but it works fine for me in FF 1.5 in windows as well as 1.5 for linux on my site

apfparadise 01-09-2006 10:50 PM

Codeman, yeah, just checked again, it does work in 1.5 Firefox. Still not in Opera. Goes out of screen. The offer def. still stands for someone who knows how to do this right.

S@NL - BlackBik 01-13-2006 10:33 PM

Does anybody know if there's a way to only resize and add a link if the image realy IS wider than the specified width?

apfparadise 01-13-2006 11:47 PM

I have been begging in several places on this site, and have offered some $$ for a script that equals the 3.0 version that was FLAWLESS. This one makes all into links, and does not resize properly, and plain does not do anything in Opera.

I thank ggiersdorf for the start, but I really wish someone would step up and finish it up. I just got a copy of the "no img for guests" finally, with a plugin and very solid.

ggiersdorf 01-14-2006 12:25 PM

Sorry guys I have been out of town for a while, just got back apfparadise what is your site?

Pm the info if you wish I will take a look and see if i can help..

bashy 01-14-2006 01:52 PM

This line is not in my class_bbcode.php im using 3.5.2

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

apfparadise 01-14-2006 06:44 PM

Bashy, the line is there, unfortunately the spacing in the post above is a bit different, so when you do a search it does not come up. Look for it manually. Took me a while too, but it's there.

ggiersdorf, I dont have it on right now, so going to my site wont help you. These are the concerns you have to look for, check them on your board too, they should be there.

1. The images that are within your set parameters should NOT be clickable, only the ones that are bigger and getting resized.

2. The images do not get resized properly. In Opera, there is no resizing for anything, just does not work, I have tried different sizes.

3. Below is a link to the 3.0 version that worked PERFECTLY I ran on my site for a long time. IT's the only one I know of that works every time. I think the new build has to start by looking at it and following that strategy. May talk to the original owner, I have asked about a port but did not get a reply.
https://vborg.vbsupport.ru/showthread.php?t=67743

BTW, I am on AIM, APFparadise. If you want to do a session I will install it quickly ( I have the edited file on my server, just need to rename 2 files) and you can take a look at it, I just dont want to run it on the site long term till it's done.

bashy 01-14-2006 07:08 PM

thanks apfparadise
That sorted it :)
Clicked install :)

S@NL - BlackBik 01-15-2006 07:39 PM

I've taken some of the code of the old hack and mixed it with the new code.
The image will now be left alone if smaller than the width you specified:
Code:

Deleted old code
Note: If you want to use the vBphrase I use, check this post .

S@NL - BlackBik 01-15-2006 09:31 PM

OK, found out that I've introduced error messages on forumpages when the image wasn't found. So I ripped some more code from the old hack by Steve St.Lauren and added it to the new code by ggiersdorf.
Seemes it works fine now :)

Code:

Check the revised code in post #52
Note that I introduced two more phrases (image not found and imageserver offline). Feel free to use plain text instead. Otherwise, don't forget to add those (global) prhases ;)

apfparadise 01-16-2006 04:51 AM

S@NL -thanks for the work, almost there. Still does not work in Opera, it links the file but does not resize it. The other two browsers are spot on, I changed the size to 800 px so maybe I made a mistake. I changed the first one that says "If image is more than ..." and made 800 and then I changed both browser options to 800 (the IE one is 800 ? 800 right?) and it works fine on IE and Firefox, but not Opera.

Also, what is the phrase for resizing supposed to do, it does not show it anywhere. I thought it would be a text line under the image to show that it should be clicked.

Also, I am not sure, but can it be made when the image is not available or the server times out for it to show an image? I created two images like this:

https://vborg.vbsupport.ru/

and

https://vborg.vbsupport.ru/

Can they be shown if there is no image?

again, thx for this.

Zia 01-16-2006 05:05 AM

hello...its a really hack...been long time looking for one that works propely..
as i saw here image hosted on other site like imageshack or photobucket..
will that image also be resized as per my requairment?
also lots of CODE here..kinda taugh to reliasize which one is for what?

just any one can tell me..
will this hack re-size/clikable image that hosted on imageshack works on IE,Opera,FireFox..

Waiting for help

Thankx.


All times are GMT. The time now is 10:22 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.01535 seconds
  • Memory Usage 1,855KB
  • 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
  • (7)bbcode_code_printable
  • (3)bbcode_php_printable
  • (6)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
  • (40)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