Feature

rendering external images

Summary

open
Sep 10, 2009
Sep 10, 2009 / damian2
Sep 10, 2009 / damian2
 

Attached files

No files uploaded
 
i made a mod for rendering external images in the form:
[[http://url/image.png|options]]

is this mod admissible for trunk?

the change in render_wiki.inc.php:

--- a/Development/Streber/render/render_wiki.inc.php	Mon Sep 07 17:09:58 2009 +0200
     1.2 +++ b/Development/Streber/render/render_wiki.inc.php	Thu Sep 10 10:32:09 2009 +0200
     1.3 @@ -1029,12 +1029,11 @@
     1.4              $this->target= asCleanString($matches[1]);
     1.5              $this->options= split(",", preg_replace("/[^a-z,=0-9]/", "", strtolower($matches[2])));
     1.6              $this->name=$matches[3];
     1.7 -
     1.8          }
     1.9          ### id|title ###
    1.10          else if(preg_match("/\A([^\|]+)\|([^|]+)$/", $str, $matches)) {
    1.11              $this->target=asCleanString($matches[1]);
    1.12 -            
    1.13 +          
    1.14              $this->name  =$matches[2];
    1.15  
    1.16          }
    1.17 @@ -1046,9 +1045,39 @@
    1.18  
    1.19  
    1.20          /**
    1.21 +        * external images
    1.22 +        */
    1.23 +        if(preg_match("/\A([\w]+)\:\/\/(\S+)\.(png|jpg|gif)/",$this->target, $matches)) {
    1.24 +			if($this->name) {
    1.25 +				$this->options=split(",", preg_replace("/[^a-z,=0-9]/","",strtolower($this->name)));
    1.26 +				$this->name = asHtml($file->name);
    1.27 +				}
    1.28 +			$align='';
    1.29 +			$max_size= 500;
    1.30 +			$framed= false;
    1.31 +			if($this->options) {
    1.32 +				foreach($this->options as $o) {
    1.33 +					if($o == 'left') {
    1.34 +						$align= 'left';
    1.35 +					}
    1.36 +					else if($o == 'right') {
    1.37 +						$align='right';
    1.38 +					}
    1.39 +					else if(preg_match('/maxsize=(\d*)/',$o, $matches)) {
    1.40 +						$max_size=$matches[1];
    1.41 +					}
    1.42 +				}
    1.43 +			}
    1.44 +			$this->html = "<a href='".$this->target."'>"
    1.45 +					   . "<img class='$align uploaded'"
    1.46 +					   .     " src='" .$this->target."'"
    1.47 +					   .     " width=" .intval( $max_size)
    1.48 +					   . "></a>";
    1.49 +		}
    1.50 +        /**
    1.51          * urls
    1.52          */
    1.53 -        if(preg_match("/\A([\w]+)\:\/\/(\S+)/",$this->target, $matches)) {
    1.54 +        else if(preg_match("/\A([\w]+)\:\/\/(\S+)/",$this->target, $matches)) {
    1.55              $type       = asKey($matches[1]);
    1.56  
    1.57              $target     = $matches[2];

No Comments