[release]Image width and height BBcode

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Locked
Robinhier
Registered User
Posts: 23
Joined: Sat Mar 13, 2004 12:12 pm
Location: Amsterdam
Contact:

[release]Image width and height BBcode

Post 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
Last edited by Robinhier on Sun Feb 27, 2005 8:06 pm, edited 2 times in total.

webkid007
Registered User
Posts: 34
Joined: Thu Feb 17, 2005 2:11 am

Post 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?

Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post 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
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.

Robinhier
Registered User
Posts: 23
Joined: Sat Mar 13, 2004 12:12 pm
Location: Amsterdam
Contact:

Post by Robinhier »

sorry for the late reply :P

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

PAS
Registered User
Posts: 7
Joined: Tue Mar 01, 2005 12:26 pm

Image Width and Height mod

Post 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

Thallium
Registered User
Posts: 395
Joined: Mon Aug 30, 2004 12:30 am
Contact:

Post 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
Complete phpBB powered websites, Mods/Hacks installed, unique templates, updates and repairs... reasonable. Email, PM or IM.

oj@ekillzzz
Registered User
Posts: 25
Joined: Sat Feb 26, 2005 11:49 am

Post 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?

User avatar
smithy_dll
Former Team Member
Posts: 7630
Joined: Tue Jan 08, 2002 6:27 am
Location: Australia
Name: Lachlan Smith
Contact:

Post by smithy_dll »

Locked under this document. Details for reclaiming the thread are within.

Locked

Return to “[2.0.x] MODs in Development”