resize images in forum? (Technics)
Hi,
Whats wrong?
It is not implemented yet, but I make some changes in the functions.inc.php
(line: 432ff - function: do_bbcode_img
) and it seems that it works
Now, you can using one of the following conventions:
/* Old ones */
// Default
[img]http://example.org/sample.pic[/img]
// float: left
[img=left]http://example.org/sample.pic[/img]
// float: right
[img=right]http://example.org/sample.pic[/img]
/* New ones */
// width: 150px; height: 200px (in general: WWWxHHH)
[img=150x200]http://example.org/sample.pic[/img]
// width: 150px; height: 200px; float: left (in general: WWWxHHH,left)
[img=150x200,left]http://example.org/sample.pic[/img]
// width: 150px; height: 200px; float: right (in general: WWWxHHH,right)
[img=150x200,right]http://example.org/sample.pic[/img]
Here, my Modification:
/** * processes BBCode images */ function do_bbcode_img($action, $attributes, $content, $params, &$node_object) { $regExp = "/^([0-9]+)x([0-9]+)(,(left|right))?$/"; if ($action == 'validate') { if(!is_valid_url($content)) { return false; } else { // [img]image[/img] if(!isset($attributes['default'])) return true; // [img=xxx]image[/img] elseif(isset($attributes['default']) && ($attributes['default']=='left' || $attributes['default']=='right')) return true; // [img=WWWxHHH]image[/img] elseif(isset($attributes['default']) && (preg_match($regExp, $attributes['default'], $imgOptions))) return true; else return false; } } else { // [img]image[/img] if(!isset ($attributes['default'])) return '<img src="'.htmlspecialchars($content).'" alt="[image]" />'; // [img=WWWxHHH]image[/img] oder [img=WWWxHHH,left|right]image[/img] if(preg_match($regExp, $attributes['default'], $imgOptions)) { // Auslesen der Bildgroesse $imgSize = "width:" . $imgOptions[1] . "px;height:" . $imgOptions[2] . "px;"; // ggf. ist left bzw. right auch gesetzt. Da Pruefung unten erfolgt, kann hier einfach // der letzte Wert aus dem Option-Array uebergeben werden. $attributes['default'] = $imgOptions[count($imgOptions)-1]; } else $imgSize = ""; // [img=xxx]image[/img] if($attributes['default']=='left') $padding='0px 10px 10px 0px'; elseif($attributes['default']=='right') $padding='0px 0px 10px 10px'; else $padding='0px'; // wann tritt das ein??? return '<img src="'.htmlspecialchars($content).'" style="'.htmlspecialchars($imgSize).'float:'.htmlspecialchars($attributes['default']).';padding:'.$padding.';" alt="[image]" />'; } }
Regards
Micha
--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences