PDA

View Full Version : Auto Resize large images in an IMG tag


mr.gamesbay
06-04-2006, 10:00 PM
First, sorry about my bad english :rolleyes:

With this small hack, all large images in an IMG Tag will be resized after the site has loaded. With a click on the resized imge, it will open in an new window with the original size. Works in Firefox, Opera, IE and i think in all other browser.
Here is a Demo: Link (http://www.gamesbay.de/showthread.php?t=128)

INSTALLATION:

--------------------------------

- Copy the file resizevbimg.js in the dir clientscript.

--------------------------------

Open the file includes/class_bbcode.php
Search the line(~line 1831):

return '<img src="' . $link . '" border="0" alt="" />';
and replace with:
return '<img src="' . $link . '" border="0" alt="" id="vBCodeIMG" />';
Save and upload.

--------------------------------

Styles & Templates > Search the SHOWTHREAD Template
Seach:
<body onload="$onload">
Replace with:
<body onload="$onload;vbImageResize()">
Save the template.

--------------------------------

Styles & Templates > Search the NEWREPLY Template
Search:
<body$onload>
Replace with:
<body onload="$onload;vbImageResize()">
Save the template.

--------------------------------

- Styles & Templates > Style Manager > Common Templates > headinclude
Search:
<!-- / CSS Stylesheet -->
After, add:
<script type="text/javascript" src="clientscript/resizevbimg.js"></script>
Save the template.

--------------------------------

Styles & Templates > Style Manager > Main CSS > Additional CSS Definitions

After, add:
.vbimgcodelimit {
cursor: pointer;
border: dotted 1px black;
}
Save.
--------------------------------

Done :)

mr.gamesbay
06-05-2006, 05:24 AM
< Post reserved for future use >

Tralala
06-05-2006, 05:43 AM
Looks good; I am currently using this hack (https://vborg.vbsupport.ru/showthread.php?p=867393#post867393) and get similar results. How do the two methods compare?

utw-Mephisto
06-05-2006, 05:58 AM
What does it do with images smaller than the pre-configured size ?

mr.gamesbay
06-05-2006, 05:59 AM
What does it do with images smaller than the pre-configured size ?
Nothing :)

rmxs
06-05-2006, 06:27 AM
resize the image after load......
I use small piece of code that resize the IMAGE ON LOAD..

Byt its cool...

utw-Mephisto
06-05-2006, 07:04 AM
VERY nice ... sorry, one more question .. the size is customizeable ?

edit :


var vbimgcodeWidthMax = 500;
var vbimgcodeWidthSizeTo = 500;


never mind ;)

shadowevil
06-05-2006, 08:53 AM
Mod nice *install*

Ahsin1
06-05-2006, 11:03 AM
Nice hack gona install later

Rich
06-05-2006, 11:43 AM
It works in IE and Opera, but I can't get it to work in FF. It is hiding the images completely.

Qwest
06-05-2006, 11:51 AM
That's the problem with using JS for stuff.

That's why I always like to do things server side to mitigate any browser compatibility issues.

mr.gamesbay
06-05-2006, 11:57 AM
It works in IE and Opera, but I can't get it to work in FF. It is hiding the images completely.

I using only Firefox for browsing and i have no problem. Perhaps the problem is an Extension in Firefox.

Kihon Kata
06-05-2006, 12:59 PM
It works in IE and Opera, but I can't get it to work in FF. It is hiding the images completely.
worked for my firefox

utw-Mephisto
06-05-2006, 03:58 PM
worked for my firefox

Any aditional plugins installed or on default installation ? Just want to be sure it'll work for all my FF user before I install it ..

Ahsin1
06-06-2006, 12:29 AM
Not working for me

PabloAM
06-06-2006, 03:32 PM
For news in vbadvanced don?t resize the imgs :(

you will go for fix???

COBRAws
06-06-2006, 08:28 PM
Dunno whats the diff between the existing hacks for image resize, so I wont bother installing.

Perhaps, if you stated the diff I would install. Thank you.

KOKS@LN
06-08-2006, 12:06 AM
I'm very grateful to you. Thanks a lot.

At last I could find a working mod. I've tried most of the other mods which is intented to auto resize oversized images. They may work for some others. And thanks to them as well.

But this mod worked both on IE and Firefox 1.5.0.4 on a vB 3.5.4 forum.

BTW I've customised resizevbimg.js for 680px and translated the phrase into Turkish. No problem with doing that ;)

Thansk again. I had been really bored with big images in posts and signatures which spoil the view.

sam anders
06-08-2006, 05:22 PM
does any one know which file i edit to change the resize values?

i see some one else mentiond the lines of the code but i can seem to find the file that contains the coding

KOKS@LN
06-10-2006, 12:53 PM
open resizevbimg.js

I've changed the value as following

var vbimgcodeWidthMax = 680;
var vbimgcodeWidthSizeTo = 680;

sam anders
06-11-2006, 11:40 AM
thanks for the info :)

tormento
06-15-2006, 10:03 AM
is possible to autoresize the attachment file?

reismarktq2
06-15-2006, 05:30 PM
Thanks, great hack!

/me clicks install

Spika
06-30-2006, 09:10 PM
Great hack! Works fine in Firefox and Ie

DarKNull
07-04-2006, 06:45 PM
oh man..i installed it and it messed up my board..i reversed everything but still can't get my forum back to normal. the threads just doesn't load anymore ;(

The following error occurred when attempting to evaluate this template:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/crickets/public_html/desihotty/includes/adminfunctions_template.php(3537) : eval()'d code on line 324

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.

JimmyN
08-06-2006, 09:33 AM
nice work, this is great for those to big images, iv had a heap of probelms with the skin being streached across the screen.

UZFRED
08-21-2006, 05:39 PM
Does this work for 3.6.0? If so could you please update the thread and change it to 3.6.0? Great hack, been loving it since I installed it ;).

ctsolutions
08-23-2006, 08:20 PM
Does this work for 3.6.0? If so could you please update the thread and change it to 3.6.0? Great hack, been loving it since I installed it ;).

yes, 100%.

tested with IE,Opera 9.1, FF.

I have installed on my vbulletin 3.6 and working like a charm.

Many thanks mr.gamesbay

you can push your hack to 3.6

mike

kofoid
09-01-2006, 10:49 PM
works great! One question - when it resizes a picture, it ends up stretching my header/logo to a gigantic size... Should I put the css code at the beginning of the additional info area?

Chriss74
09-02-2006, 09:49 PM
Nice Hack!

For my purpose, I made a small, but effective change:

var vbimgcodeWidthMax = screen.width-420;
var vbimgcodeWidthSizeTo = screen.height-300;


(Depending on the individual forum layout, you should sample different values instead of 420 and 300.)

Now the max image-size depends on the screen-resolution of the visitor. Do the visitor have a high screen-resolution, he will see a greater pic than a visitor, that have a lower screen-resolution. In any case, the screen resolution will be used to its full capacity, without the problem, that the forum-layout gets destroyed, because of oversized pics.

Greetings,
Chriss

Elbarfo
04-17-2007, 05:32 PM
Was looking for a cleaner solution for 3.6.5 and this worked perfectly!

I can't believe this isn't supported. It's certianly a lot cleaner solution that many others I've seen.

Easy breezy!

Tested in FF, and IE6 &7

Thanks!

midnightwalker
05-18-2007, 06:19 AM
didn't work on mine :(

Please check:
http://rmitportal.info/forum/showthread.php?t=4523

flup
05-18-2007, 09:49 PM
Not working for me on vB3.5.4 ... too bad :(

flup
05-18-2007, 10:01 PM
Got it working, FlashFXP didn't overwrite my file ;)

flup
05-19-2007, 11:28 AM
Any chance to combine this with LightBoxv2 ?

flindersredclaw
08-03-2007, 01:04 AM
works in 3.6.8 no probs - I am using it for vbimage host picture display and others

crakker56
02-22-2008, 06:47 PM
I know there is a way, but I don't know how to do it.

How can I add a line that says "Click image to see original size" ??

EDIT - I see it says that in the resizevbimg.js file but it does not show up on my site. Any clue?

crakker56
02-26-2008, 12:06 AM
anyone??

flup
12-16-2008, 02:46 PM
Works like a charm, thanks

flup
12-16-2008, 02:47 PM
@crakker56:

try this; in includes/class_bbcode.php replace:

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

with

return '<img src="' . $link . '" border="0" alt="" id="vBCodeIMG" /><br />click image to see original size';