PDA

View Full Version : Another BB tag to resized linked images


cinq
12-03-2003, 05:24 AM
Not a hack as no editting of PHP files are involved, though I'd like to share it.

What it does ?

When users link images, at times the images linked are a tad too big for your forum layout and spoils the look of the page.

This new bb code, provided the images are linked using this BB code, will allow smaller thumbnails to retain the layout of the page.

The image is not resized per se, it is just viewed as resized so that it would not spoil the page layout.

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

Steps to perform
Add a new BB code ( AdminCP -> Custom vB Codes -> Add

vB Code tag

img2


vB Code replacement

<img src={param} border='2' onload="javascript:if(this.width>screen.width-600){ this.height=Math.round(((screen.width-600)/this.width)*this.height); this.width=(screen.width-600);}" onclick="javascript:window.open('{param}','','scrollbars=1' )"/>
<br><smallfont>&nbsp;* Image resized. Click on image to view full size.</smallfont><br>


vB Code example

http://www.yoursite.com/forum/images/banner.jpg


Use {option} ?
Select No.
-------------------------------------------------------

Notes:
Thumbnail sizing is proportionate. It can be changed by altering the value 600 in the code replacement bit.
-------------------------------------------------------

Hope this proves useful. :)

cinq
12-03-2003, 05:26 AM
Once done, to use this , simply put the image to be linked btw the following tags :


XX

cinq
12-30-2003, 11:52 PM
Sorry , just an update on this :
I have found that you need to do an SQL Query first for this to work without errors ( without doing this step , I encountered errors in the admincp when adding the code replacement )


Run the following query:

ALTER TABLE bbcode CHANGE bbcodereplacement bbcodereplacement LONGTEXT NOT NULL;

cinq
12-30-2003, 11:55 PM
And while checking around for how to make current linked images ( ie those using [ img] tags ) similiarly resized, chanced upon some code provided by Zzed in one of his hacks (here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=50882)) which can be used here as well.


In admin/functions.php:
Look for:


function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmi lies,$dobbcode)
{ // parses text for vB code, smilies and censoring

global $DB_site,$wordwrap,$allowdynimg, $bbuserinfo;

static $smilies,$bbcodes;
global $regexcreated,$searcharray,$replacearray,$phpversi onnum;


Add below:

$bbcode = preg_replace("/img\]/i", "img2]", $bbcode);


This will replace all linked images using the [ img] tags with the new [ img2] tag automatically.

MaDCaT75
12-31-2003, 07:57 AM
This works great except for people who have image signatures :\

cinq
12-31-2003, 08:26 AM
That's something that I have not found a work around yet however as ALL img tags will be amended to use img2 :(
However if the images in their sigs are that big that they must be resized.... woah.... :D

MindTrix
12-31-2003, 04:16 PM
im pretty sure there is a mod at www.vbulletintemplates.com (http://www.vbulletintemplates.com) which re-sizes signature images. I think it worked that if they had an image over the limit, it cut the image too the proper size.

chrisvonc
02-04-2004, 04:09 PM
I tried this on 2 test platforms (vB 2.3.2) and I cant get it to resize the pictures at all no matter what numeric value I put in. Any ideas?

Thanks!

Chris