resize images in forum? (Technics)

by Don Dubuque @, Wednesday, September 16, 2009, 00:17 (5308 days ago)

I have bbcode on but the following will not resize my images or show them.

[img=300x300]http://www.m2inc.com/products/6m/6m5x.GIF[/img]

Whats wrong?

Avatar

resize images in forum?

by Micha ⌂, Sunday, November 01, 2009, 13:50 (5261 days ago) @ Don Dubuque

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

Avatar

resize images in forum?

by Micha ⌂, Monday, April 30, 2012, 05:54 (4351 days ago) @ niels

same problem here, just won't show in a forum post

[image]

works as designed...

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

resize images in forum?

by recthor, Wednesday, June 05, 2013, 07:48 (3949 days ago) @ Don Dubuque

to resize image , you can employ some professional softwares, I use an imaging sdk found on the internet which can resize images . Install it and it becomes a selectable processing option.Then you can resize images in any program at all, including Adobe Acrobat . Just open the images, select resize ,and follow the setps given in the sdk, the task will be finished in several seconds.you can then zoom in and zoom out the picture on your own will. if you haven´t found a good choice , you can have a try. best wishes.

resize images in forum?

by Rachana11, Monday, August 01, 2022, 06:00 (606 days ago) @ Don Dubuque

you can try jpeg compressor tool for free online service, you can resize your image files for forum this tool resize your image without losing the original image quality.

RSS Feed of thread