Page 1 of 1

[release]Image width and height BBcode

Posted: Tue Feb 15, 2005 7:05 pm
by Robinhier

Code: Select all

############################################################## 
## MOD Title: Image width and height BBcode 
## MOD Author: robinhier < admin@robintown.nl > (Robin van der Markt) http://www.robintown.nl 
## MOD Description: With this mod you can set the weidth and height of an image via the BBcode ([img width=xxx height=xxx]URL[/img]
## MOD Version: 1.0.1
## 
## Installation Level: (Easy) 
## Installation Time: 5 Minutes 
## Files To Edit: bbcode.php, bbcode.tpl 
## Included Files: (n/a)
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: 
## My first 'real' mod :P
############################################################## 
## MOD History: 
## 
## 2005-02-15 - Version 1.0.0 
## - release
## 
## 2005-02-27 - Version 1.0.1
## -Typo fix and the code in the description
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/bbcode.php

# 
#-----[ FIND ]------------------------------------------ 
# 
	$bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	$bbcode_tpl['imgwh'] = str_replace('{URL}', '\\3', $bbcode_tpl['imgwh']);
	$bbcode_tpl['imgwh'] = str_replace('{WIDTH}', '\\1', $bbcode_tpl['imgwh']);
	$bbcode_tpl['imgwh'] = str_replace('{HEIGHT}', '\\2', $bbcode_tpl['imgwh']);

# 
#-----[ FIND ]------------------------------------------ 
# 
	// matches a [url]xxxx://www.phpbb.com[/url] code..

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
	// [img width= height= ] and [/img] code..
	$patterns[95] = "#\[img width=([0-9]?[0-9]?[0-9]) height=([0-9]?[0-9]?[0-9]):$uid\](.*?)\[/img:$uid\]#si";
	$replacements[95] = $bbcode_tpl['imgwh'];

# 
#-----[ FIND ]------------------------------------------ 
# 
	// [img]image_url_here[/img] code..
	$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
	// [img width= height=] and [/img] code..
	$text = preg_replace("#\[img width=([0-9]?[0-9]?[0-9]) height=([0-9]?[0-9]?[0-9])\](([a-z]+?)://([^, \n\r]+))\[\/img\]#si","[img width=\\1 height=\\2:$uid\]\\3[/img:$uid]", $text);

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/bbcode.tpl

# 
#-----[ FIND ]------------------------------------------ 
# 
<!-- BEGIN img --><img src="{URL}" border="0" /><!-- END img -->

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
<!-- BEGIN imgwh --><img src="{URL}" width={WIDTH} height={HEIGHT}></img><!-- END imgwh -->

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 
Text file: http://www.robintown.nl/RobinMods/Image ... BBcode.txt

Posted: Mon Feb 21, 2005 6:49 pm
by webkid007
hey robin,

it appears u read my mind! thanks for the mod :)


please specify where do you put your desire width #.
where in the code do you plug in the width number?

Posted: Mon Feb 21, 2005 11:31 pm
by Thallium
What is the syntax to use for the bbcode? Is it something like [img width="640" height="480"] or what? :?

Also a typo:

Code: Select all

#-----[ AFTER, ADD ]------------------------------------------
#
   // [img width= heigth=] and [/img] code..
heigth should be height. Will be a very useful MOD though, thanks for writing it. :lol:

---Thallium

Posted: Sun Feb 27, 2005 8:03 pm
by Robinhier
sorry for the late reply :P

It's [img width=xxx height=xxx]URL[/img]

Image Width and Height mod

Posted: Fri Mar 04, 2005 4:17 pm
by PAS
Hi.
Can you please tell me if this mod is supposed to automatically adjust the image width and height when its installed or do posters still have to add the commands to the [img] switch?

I ask because i have installed it but it doesnt automatically insert the switches when you click [img] and i dont know if its supoosed to be like that or if i have an error when i modded it

Thanks for your help
Phil

Posted: Fri Mar 04, 2005 4:29 pm
by Thallium
I could be wrong but I think you have to add the dimensions you want to use manually, and that just using the [img ] tag as usual will not have any different effect on the image.

---Thallium

Posted: Fri Mar 04, 2005 4:33 pm
by oj@ekillzzz
is there a way that when the img button is hit it auto reizes the pic to a default size so all pics are the same size?

Posted: Tue Oct 11, 2005 12:06 pm
by smithy_dll
Locked under this document. Details for reclaiming the thread are within.