Pagina 1 van 1

bbcode: formaat van afbeeldingen aanpassen

Geplaatst: 22 jul 2005, 18:40
door Pien
vroeger op de oude versie kon ik met bbcode het formaat van een afbeelding aanpassen. nou heb ik daar een mod voor gevonden maar ik krijg het niet aan de gang:
##############################################################
## 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
## MOD Version: 1.0.0
##
## 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
##
##############################################################
## 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= heigth=] 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

Klopt ie wel? Daarnaast zou ik ook eigenlijk iets willen waarbij ik alleen de breedte of de hoogte hoef in te vullen en dat verder de verhoudingen gelijk blijven. Kon vroeger ook geloof ik.