View Full Version : Auto Resize Your Images 3.52 compliant
ggiersdorf
12-27-2005, 10:00 PM
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
return '<img src="' . $link . '" border="0" alt="" />';
replace with the following.
/* 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:
/* 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:
/* 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...
/* 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:
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
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:
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?
[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
@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
Does this work on v. 3.5.3?
Yes it should work fine on 3.53
ggiersdorf
01-07-2006, 09:50 AM
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!?
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/8256/vidaguerramix0014ck.th.jpg (http://img280.imageshack.us/img280/8256/vidaguerramix0014ck.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 :)
/* 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
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:
Deleted old code
Note: If you want to use the vBphrase I use, check this post (https://vborg.vbsupport.ru/showpost.php?p=869113&postcount=26) .
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 :)
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.
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.
S@NL - BlackBik
01-16-2006, 08:44 AM
S@NL -thanks for the work, almost there. Still does not work in Opera, it links the file but does not resize it.
I didn't test it in Opera because only 1% of our users use Opera.
Remember I'm not a coder, I just took two hacks and tried to combine them. I have no clue why it's not working in Opera. Maybe you'll have to let Opera identify itself as MS-IE.
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.
Good to hear the other browsers are working :)
Yes, there are three instances where you have to change the size to the one you want. The IE one is 800 ? 800.
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.
The "click message" is a "alt-tag" in the image that shows when you hoover you're mouse over the shrinked image. With the phrase you can change the message that appears. It is not a text line under the image. I introduced the phrases cause we run a multilanguage board ;)
When you're not, you can easely change the phrases to hardcode text.
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:
<snap>
and
<snap>
Can they be shown if there is no image?
again, thx for this.
I don't know. Right now it's just a text in a small table. It may be possible to use the image. Just substitute the phrases for a imagetag and see if it works.
And you're welcome. I needed this for myself, that's why I looked in to it :)
S@NL - BlackBik
01-16-2006, 08:47 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.
Hello Zia.
The code in the first post is the official hack by ggiegersdorf.
I just costumized this code. The latest revision of my code is in post #38.
This will resize every image when it's wider than the specified width. It does work in IE and Firefox. It doesn't seeme to work in Opera.
apfparadise
01-16-2006, 08:01 PM
S@NL - it's the funniest thing. My opera was setup to identify as IE. After your comment I went to check, switched it to "Identify as Opera" and it works :) Now it's working flawlessly, except I gotta work out how to properly add the tag on the bottom. Will get it tonight, and post here.
S@NL - BlackBik
01-16-2006, 09:50 PM
LOL, just let Opera work as designed (as itself that is) and it works :)
OK, that's good to know.
I found a little bug though.
It seemes that image url's with al space in it, that translates to %20, can not be displayed by this hack. Have to look into that....
Hello Zia.
The code in the first post is the official hack by ggiegersdorf.
I just costumized this code. The latest revision of my code is in post #38.
This will resize every image when it's wider than the specified width. It does work in IE and Firefox. It doesn't seeme to work in Opera.
Thankx Man..
Its does'nt work on opera.....it could be okay some time..tho personally i use opera..
but theres a porbs ..it also resize sigs.....infact image posted in a post that image will be resize or thumnail (100X75) .
our sigs limit is : 300X100.
all of the sigs turn to 100X75 ... :ermm:
can u tell me how to do that...this modification only works on image that posted in a post..& it will ignore the image in sigs..
plz let us know urgently...getting lots of complain from user..... :surprised:
apfparadise
01-17-2006, 05:09 AM
S@NL, now if you only could place the code in for the border with the "Click to see full size image" so that I dont have to break my brain trying to figure it out and fail, that would be awesome.
S@NL - BlackBik
01-17-2006, 08:09 AM
Its does'nt work on opera.....it could be okay some time..tho personally i use opera..
It does work in Opera. Just let Opera identify itself as Opera and not as MSIE. See the post just above yours.
but theres a porbs ..it also resize sigs.....infact image posted in a post that image will be resize or thumnail (100X75) .
our sigs limit is : 300X100.
all of the sigs turn to 100X75 ... :ermm:
can u tell me how to do that...this modification only works on image that posted in a post..& it will ignore the image in sigs..
Just don't resize the images to such a small size but set the width parameters to 300 (same as your sig images).
I don't know how to not make this work on sigs.
As I said, I'm not a coder, nor do I support this hack. I just want to share some modifications I made to the code from ggiegersdorf. If you can't use it, then don't.
I'm not gonna code stuff I don't want to use on my own board.
The only thing I will do is try to sort out why some images aren't showing when there is some special character in it's url. For the rest you're on your own ;)
got ur word.. S@NL - BlackBik
as i read it..it wont touch the image if the image, is smaller than defined size inside hack....
so now i can change resized image hack larger than sigs(300X100)
like 300X225..
in that case it wont touch the sigs..
in that case it wont create thumbnail & wont touch the sigs??
hehe so many qus?
rater should i PM the main author? :surprised:
got ur word.. S@NL - BlackBik
as i read it..it wont touch the image if the image, is smaller than defined size inside hack....
so now i can change resized image hack larger than sigs(300X100)
like 300X225..
in that case it wont touch the sigs..
in that case it wont create thumbnail & wont touch the sigs??
hehe so many qus?
rater should i PM the main author? :surprised:
umm want that this mod will create thumbnail to 100X100 but it wont touch sigs.so sigs size will remain as it is/was
S@NL - BlackBik
01-17-2006, 11:42 AM
got ur word.. S@NL - BlackBik
as i read it..it wont touch the image if the image, is smaller than defined size inside hack....
so now i can change resized image hack larger than sigs(300X100)
like 300X225..
in that case it wont touch the sigs..
in that case it wont create thumbnail & wont touch the sigs??
hehe so many qus?
rater should i PM the main author? :surprised:
umm want that this mod will create thumbnail to 100X100 but it wont touch sigs.so sigs size will remain as it is/was
This mod was NOT designed to make thumbnails.
Just to make images smaller so they don't mess up the forumlayout.
That's why the sizecheck ONLY checks the width of the image and NOT the height.
But now I understand your problem. And you understood ok, if you define the maximum width of a image bigger or as big as your signature images, it won't touch the them.
Marris
01-18-2006, 01:33 AM
Is it possible to have this resize modification only affect bbcode parsing when it is called from the vBadvanced news.php module?
I'd like to do something like the following, but I'm not sure of the exact syntax and whether or not I can determine the page/script name within class_bbcode.php.
EDIT: Nevermind, I got it working 5 seconds after I posted with the following:
if (THIS_SCRIPT == 'adv_index'){
$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>';
}
} else {
return '<img src="' . $link . '" border="0" alt="" />';
}
S@NL - BlackBik
01-18-2006, 11:04 PM
OK guys,
Here is the last revision of my code. Finaly got it working:
/* Start hack Image RESIZE */
// Check to see if image exists
$link = str_replace(" " , "%20", $link);
$link = str_replace("&" , "%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="" />'; */
What it does:
Check if the database server is online
Check if the image is available
Check the width of the image
If > 600 width, resize to 600 and place a link under it to click for the orginal image
It doesn't touch the image when =< 600 width.
The problem with not being able to cope with spaces or ampersands in the url is solved.
If you are gonna use this, be sure to add the three phrases.
You can costumize the width that you want as limit for resizing by changing the three instanses of "600" in the code to the limit you want.
I don't want to take credit for this code because I did nothing else than changing the existing code that was allready there :)
Enjoy :)
Codeman05
01-19-2006, 12:05 AM
seems to make the pages take alot longer to load...or is it just me?
apfparadise
01-19-2006, 06:24 AM
.... and place a link under it to click for the orginal image
I dont see that in the code or on my site. :) Do you mean it makes image into a link? Or actual line of text under the image that says something like: "This image has been resized, please click on it to see the full version"? 'Cause that would be great, to make it easy for the members to know when it's resized.
S@NL - BlackBik
01-19-2006, 11:26 AM
seems to make the pages take alot longer to load...or is it just me?
Yes, if you open a page with a lot of pictures, it can take longer.
That's because each picture is validated and that's a extra process in opening the page.
Pages with no pictures of just a few will not be affected.
S@NL - BlackBik
01-19-2006, 11:35 AM
I dont see that in the code or on my site. :) Do you mean it makes image into a link? Or actual line of text under the image that says something like: "This image has been resized, please click on it to see the full version"? 'Cause that would be great, to make it easy for the members to know when it's resized.
Sorry, but English is not my native language. I'm Dutch and sometimes it ain't easy to express exactly what you want to say.
With "under it" I meant that when you hoover over the picture you see a resize message and the cursor changes into a hand. Then you can click the picture for a larger image.
If you want this text litteraly under the picture, you might try this:
Find:
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:
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 didn't test it but it should do the trick :)
Again, don't forget to add the vbphrases, or substitute in above code ' . $vbphrase['click_for_larger_image'] .' for hard coded text like "Click for larger image".
S@NL - BlackBik
01-19-2006, 11:45 AM
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:
http://aquatic-photography.com/pics/noimage.gif
and
http://aquatic-photography.com/pics/noserver.gif
Can they be shown if there is no image?
I think this is your last issue and this should not be to difficult to address.
Find in the code of post #52 the next code:
// 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>';
}
and change is to this:
// Image not found
return '<img src="http://aquatic-photography.com/pics/noimage.gif" border="0" alt="" />';
}
} else {
// Server is down
return '<img src="http://aquatic-photography.com/pics/noserver.gif" border="0" alt="" />';
}
I didn't test this either but i'm pretty sure it works :)
A-handreas
01-19-2006, 12:54 PM
Your code is good, but I have a lot of pictures in my forums. It took some seconds to saw the thread while the pictures are checked before the thread would be visible. The user think my forum is slow. Any chance to modify this, because I know the original code was f*cking fast
S@NL - BlackBik
01-19-2006, 01:08 PM
Sorry A-handreas, as I said before I'm not realy a coder. I just combined two pieces of code to make another one and succeeded (to my own suprise) to make that work.
I lowered the time-out variable on the @fsockopen() command from 5 to 2. That might speed things up a little.
But I'm not aware of php code that could do those checks faster.
Maybe some *real* coders know a quicker way.
Puntoboy
01-19-2006, 06:36 PM
so it this hack like what you get on invision power boards?
when someone posts and image linked from another site/gallery it will resize the image so it keeps the thread structure aligned?
if so, how do i insert this code? whats the final code that works?
S@NL - BlackBik
01-19-2006, 11:27 PM
The final code that works is in the first post of the thread.
The code I tweaked is in post #52.
Just read this thread and choose what you like.
And as I don't know Invisionboard.... Well it may be the same and then again, it may not :D
Puntoboy
01-19-2006, 11:47 PM
wicked mate cheers.
yeah work exactly like IPB.
PennylessZ28
01-21-2006, 11:00 PM
Heres the problem with this, it turns every [img] tag into a resize and link.
so now signature images are clickable. BOO
Puntoboy
01-23-2006, 10:34 AM
yes i get the same error.
S@NL - BlackBik
01-23-2006, 12:59 PM
yes i get the same error.
It's not an error, it's the way this hack works....
But when you don't set your max image resize size in the hack to small and the sigpic max size to high, they will not be affected by this hack. On my board it's not a problem ;)
Puntoboy
01-23-2006, 01:04 PM
It's not an error, it's the way this hack works....
But when you don't set your max image resize size in the hack to small and the sigpic max size to high, they will not be affected by this hack. On my board it's not a problem ;)
i'll have to remove the hack then.
lots of my members created hyperlinked images in their signatures. sue to this hack the hyperlinks dont work.
S@NL - BlackBik
01-23-2006, 01:12 PM
I looked at your forum and I see what you mean. That ain't cool, I agree.
But what is the size that you entered in the hack to let it kick in?
When you set that to 600 pixels, you won't have a problem I guess.
Puntoboy
01-23-2006, 01:14 PM
I looked at your forum and I see what you mean. That ain't cool, I agree.
But what is the size that you entered in the hack to let it kick in?
When you set that to 600 pixels, you won't have a problem I guess.
i left it as default as that seemed like the perfect size.
Puntoboy
01-23-2006, 01:26 PM
which part of the code to i need to change to 600?
S@NL - BlackBik
01-23-2006, 01:42 PM
This (in bold)
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>';
}
If you're using my version, it's the same lines ;)
In the first line, the number after the greater then sign is the width above wich the hack will resize for Internet Explorer
In the second line the number is just the width above wich the hack will do it's worst for Firefox and other browsers :)
Puntoboy
01-23-2006, 01:45 PM
ok mine is exactly like that, so i need to change both to 600 or just the 640 ? 480?
S@NL - BlackBik
01-23-2006, 01:48 PM
Both is OK.
Than it will resize if the picture is bigger than 600 and will resize it to 600.
But now I realize that the original hack by ggiegsdorf will always put a link on a picture.
My version in post #52 doesn't do that, but it's performance is less quick in threads with a lot of pics.
Puntoboy
01-23-2006, 02:53 PM
so if i use your code i won't have a problem?
/* Start hack Image RESIZE */
// Check to see if image exists
$link = str_replace(" " , "%20", $link);
$link = str_replace("&" , "%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 */
vietfancy
01-23-2006, 06:04 PM
Thanks, installed
S@NL - BlackBik
01-23-2006, 08:13 PM
@Puntoboy, yes technicaly it works. It may slow down some pages with many pictures on it, but it doesn't touch images smaller than the width variable you use in the code.
Try it, and if you don't like it, than just get rid of it :)
Heres the problem with this, it turns every [img] tag into a resize and link.
so now signature images are clickable. BOO
helo...me too get the same probs (error)
after that I pm to the main coder...
i got a reply that,,hes bizi with another hack....
i gez..he should have informed about this,,,taht lots of us are facing this problem..
we want it will re-size (thumbnail) every image hosted on imageshack or photobucket ...but it should ignore sigs image..
i think u can imform him abut ur probs....
Thankx Friendz
S@NL - BlackBik
01-24-2006, 03:19 PM
Well, this isn't or ever was supported.
It's just a piece of code he has shared with us ;)
I guess that if you don't like it, you just uninstall.
The code in post #52 doesn't touch the sigs, but it has a performance problem. Because I don't know how to fix that I won't release it as a hack either ;)
Just take the original code or my version if you like it. If not, don't use it.
Maybe someone will come along that can sort the problems out and will release it as a working hack that doesn't get replies like "BOO".
ggiersdorf
01-26-2006, 12:47 PM
I have been reading this thread and working on a few things myself here. I have finally gotten the code to work 99.9% of the time in IE and Firefox I dont have nor want Opera so I have not tested this new code on it. The image are clickable but I'm working on one last thing which should make everyone here pretty happy.
(anyone who know the exact location of where signatures are displayed in the code of vbulletin please PM me I have a hack for hopefully fixing this issue also)
Hopefully once I work out this issue it will be ready to upload to you.. Code and Hack required.
I have been reading this thread and working on a few things myself here. I have finally gotten the code to work 99.9% of the time in IE and Firefox I dont have nor want Opera so I have not tested this new code on it. The image are clickable but I'm working on one last thing which should make everyone here pretty happy.
(anyone who know the exact location of where signatures are displayed in the code of vbulletin please PM me I have a hack for hopefully fixing this issue also)
Hopefully once I work out this issue it will be ready to upload to you.. Code and Hack required.
ouch...i cant say it.......
any one know it ?
really a lots people will be benifited with this..
Stangsta
01-26-2006, 05:48 PM
I have been reading this thread and working on a few things myself here. I have finally gotten the code to work 99.9% of the time in IE and Firefox I dont have nor want Opera so I have not tested this new code on it. The image are clickable but I'm working on one last thing which should make everyone here pretty happy.
(anyone who know the exact location of where signatures are displayed in the code of vbulletin please PM me I have a hack for hopefully fixing this issue also)
Hopefully once I work out this issue it will be ready to upload to you.. Code and Hack required.
Postbit and postbit legacy template.
<!-- sig -->
<div>
__________________<br />
$post[signature]
</div>
<!-- / sig -->
ggiersdorf
01-26-2006, 11:07 PM
Thanks Stangsta, I think there is another location also which is causing me an issue, mabey it's the code im using but it will take a few days and I will be back..
Cross you fingers.. :)
Snake
01-26-2006, 11:33 PM
Screenshot please?
S@NL - BlackBik
01-27-2006, 12:00 AM
Screenshot for what?
Snake
01-27-2006, 12:03 AM
Nevermind.
Alex_
01-28-2006, 07:43 AM
I have threads with lot's of images - when I use the version with getimagesize it takes a very very long time to open the thread - but when I comment out the size check every image is turned into a link even when it already was one.
This leads to the effect that clicking on an imageshack.us thumbnail you don't open the fullsize version but the thumbnail opens in another page... :(
ggiersdorf
01-28-2006, 12:14 PM
Images have to "pre-load" I have the same issues with posts with like 27 images in it. I have set mine now to anything over 500px gets scaled down to 150 allowing 3 to 4 images per line on my forum this way signatures can be upto 500 pxs without having them resized also...
PJSkiboy
01-30-2006, 02:25 AM
I'm watching this thread for the update. Sounds promising ggiersdorf. Thank you very much for all the effort.
Thanks Stangsta, I think there is another location also which is causing me an issue, mabey it's the code im using but it will take a few days and I will be back..
Cross you fingers.. :)
:banana: :banana: man......cant wait more to have that one
lazytown
01-31-2006, 07:36 AM
S@NL - BlackBik,
I had some errors on my forum with the resizing (at least I believe that's what caused it). I had a previous version of VBGallery installed. I then upgraded to VBPicGallery. So the old vbgallery pictures are now broken if posted within the forum (they are broken regardless of your mod)
Using the mod you provided, I get the following error at the very top of the forum page for certain threads.
Warning: getimagesize(http://www.myforumdomain/.com/forum/vbgarage.php?do=thumb%26width=100%26id=135): could not make seekable - http://www.myforumdomain.com/forum/vbgarage.php?do=thumb%26width=100%26id=135 in /includes/class_bbcode.php on line 1852
-vissa
lazytown
01-31-2006, 07:57 AM
So am I correct in saying that this mod is server-side? In other words, the server actually has to download the image from wherever it is linked to before it does anything with it? Couldn't the whole thing be implemented client-side with javascript? That way the user's computer is doing the work and not the forum server.
-vissa
ggiersdorf
01-31-2006, 02:43 PM
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.
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..
S@NL - BlackBik
01-31-2006, 06:42 PM
S@NL - BlackBik,
I had some errors on my forum with the resizing (at least I believe that's what caused it). I had a previous version of VBGallery installed. I then upgraded to VBPicGallery. So the old vbgallery pictures are now broken if posted within the forum (they are broken regardless of your mod)
Using the mod you provided, I get the following error at the very top of the forum page for certain threads.
-vissa
Hi Vissa,
Sorry, but I can't help you there. The error is caused by vbgarage.php and I don't use that hack. I don't have a clue why you get this error.
Yes you are right when you say my version of this hack is on the serverside. It causes extra serverload and when you have many images in a thread (including sig images) it will definitly slow your page.
There is a java hack on the cli?nt side. I'm using it now, since my users complained about long loading times. You can find it here: https://vborg.vbsupport.ru/showthread.php?t=99286&highlight=resize.
It's not as sophisticated, it doesn't show when an image is unavailable or the imageserver is down, but it's much quicker ;)
ggiersdorf's hack is also on the serverside, but it's much quicker as my version as it execute less code and doesnt get the imagesize before resizing the image.
3dsoft
01-31-2006, 07:57 PM
The image resizes correctly but the layout is still broken in Opera 8.51
What are the template changes?
lazytown
02-01-2006, 11:16 AM
Thanks for your help -- I will look at the javascript version.
-vissa
ggiersdorf
Where the signature variable is. Which I think it's $post[signature]
https://vborg.vbsupport.ru/showthread.php?t=92625
this variable was posted in that link...
dont know, mite it give some support
The_Rayman
02-10-2006, 02:05 PM
Hey S@NL - BlackBiker,
Thanks for the advanced hack!
Got it installed and works fine here in Mozilla and IE... don't use Opera... ;)
kompakt
02-23-2006, 11:35 PM
works perfectly for me, thanks :)
ggiersdorf ..helo..
umm when update will be release?
kildjean
03-03-2006, 08:35 PM
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
rhino56
03-05-2006, 03:23 PM
i used it and it worked fine, version 3.53
www.cryo-labs.com
Blown Beauty
03-08-2006, 01:51 AM
so if i use your code i won't have a problem?
/* Start hack Image RESIZE */
// Check to see if image exists
$link = str_replace(" " , "%20", $link);
$link = str_replace("&" , "%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! :)
hello....
:) when we can accept an updated that wont touch sigs ?
and re-size works with IE,opera,firefox
MotMann
03-14-2006, 04:38 PM
OK guys,
Here is the last revision of my code. Finaly got it working:
/* Start hack Image RESIZE */
// Check to see if image exists
$link = str_replace(" " , "%20", $link);
$link = str_replace("&" , "%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?
drewclark
03-26-2006, 08:11 PM
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...
chanthuyen
05-13-2006, 02:00 PM
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)
SiMateoAko
05-18-2006, 04:47 PM
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:
return '<img src="' . $link . '" border="0" alt="" />';
with this:
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.
encryption
05-19-2006, 03:13 PM
I installed the mod and the resizing works perfectly, however I cant parse images as links anymore.
Smiry Kin's
05-22-2006, 01:17 AM
works perfect in 3.5.4
Nathan2006
05-23-2006, 07:21 AM
Thank you ggiersdorf
Just what I have been looking for :D
Install;)
encryption
05-23-2006, 11:52 AM
so none of you are having the issue with parsing images as links ?
skooby
05-23-2006, 08:21 PM
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?
epicbear
05-24-2006, 05:18 PM
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?
epicbear
05-24-2006, 05:49 PM
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...:confused:
bada_bing
05-24-2006, 06:17 PM
Installed and working good so far on vb 3.5.3
Thank You
blacklancer
05-26-2006, 04:11 PM
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:
return '<img src="' . $link . '" border="0" alt="" />';
with this:
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:
Neurotoxin
05-28-2006, 02:06 AM
Awesome mod, works perfect!
Bulent Tekcan
05-28-2006, 08:07 PM
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.
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:
jags2ooo
05-29-2006, 05:49 PM
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
Djamil
06-03-2006, 04:39 PM
Find:
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:
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 52 doesn't show the phrase in the alt-tag. Any hints ?
Djamil
Djamil
06-04-2006, 12:53 PM
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
function handle_bbcode_img_match($link)
{
ADD AFTER
global $vbphrase;
Then the phrases will show up.
For further information please consult this chapter of the vB manual (http://www.vbulletin.com/docs/html/main/language_phrase_templates)
Djamil
SiMateoAko
06-12-2006, 04:35 AM
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
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:
return '<img src="' . $link . '" border="0" alt="" />';
With this line:
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 (http://news.tecnocomputer.it/forums/showthread.php?t=2343)
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/i16/Cirquerider/accident015.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)
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
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:
return '<img src="' . $link . '" border="0" alt="" />';
With this line:
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/showthread.php?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
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:
return '<img src="' . $link . '" border="0" alt="" />';
With this line:
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 (http://www.vgreality.com/testphp.php) 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:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' . $link . '" border="0" alt="" >';
With this:
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
Awesome code! Although I have a problem...
See, the reason I needed an image resizer was mostly for my news fetch (click here (http://www.vgreality.com/testphp.php) 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:
return '<img style="max-width:800px;" style= "width: expression(this.width > 800 ? 800: true);" src="' . $link . '" border="0" alt="" >';
With this:
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
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
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
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:
return '<img src="' . $link . '" border="0" alt="" />';
with this:
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:
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
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:
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.
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:
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:
return '<img src="' . $link . '" border="0" alt="" />';
with:
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:
.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-manzaralar/182-gullerin-icinden-185.html#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:
.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 (https://vborg.vbsupport.ru/showthread.php?p=1086605#post1086605) and it works a treat for me :)
smsmasters
10-07-2006, 09:01 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:
return '<img src="' . $link . '" border="0" alt="" />';
with:
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:
.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-manzaralar/182-gullerin-icinden-185.html#post224010
Actual image width is 1024 pixels (resized to 728px) and the thumbnail keeps the link.
Excellent! :)
manutdvn
10-08-2006, 04:25 PM
change:
/* 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:
/* 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
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:
return '<img src="' . $link . '" border="0" alt="" />';
with:
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:
.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-manzaralar/182-gullerin-icinden-185.html#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
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:
return '<img src="' . $link . '" border="0" alt="" />';
with this:
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
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:
return '<img src="' . $link . '" border="0" alt="" />';
with:
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:
.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-manzaralar/182-gullerin-icinden-185.html#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
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:
/* 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!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.