diff --git a/broken.svg b/broken.svg new file mode 100644 index 0000000..e31b6f2 --- /dev/null +++ b/broken.svg @@ -0,0 +1 @@ +????????->?? \ No newline at end of file diff --git a/conf/metadata.php b/conf/metadata.php index 11aefb6..4a56539 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -1,4 +1,5 @@ _imgfile($data); +$content_type = $plugin->_format == 'png' ? 'Content-Type: image/png' : 'Content-Type: image/svg+xml'; + if(!$cache) _fail(); -header('Content-Type: image/png;'); +header($content_type); + header('Expires: '.gmdate("D, d M Y H:i:s", time()+max($conf['cachetime'], 3600)).' GMT'); header('Cache-Control: public, proxy-revalidate, no-transform, max-age='.max($conf['cachetime'], 3600)); header('Pragma: public'); @@ -24,8 +27,8 @@ function _fail(){ header("HTTP/1.0 404 Not Found"); - header('Content-Type: image/png'); - echo io_readFile('broken.png',false); + header($content_type); + echo io_readFile('broken.' . $plugin->_format, false); exit; } diff --git a/lang/en/settings.php b/lang/en/settings.php index 69bf6b0..377362c 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -1,3 +1,4 @@ /usr/bin/dot). Leave empty to use remote rendering at google.com.'; +$lang['svg'] = 'Render the result to svg format. Only works when using local graphviz dot binary.'; diff --git a/syntax.php b/syntax.php index 518d027..7ea290a 100644 --- a/syntax.php +++ b/syntax.php @@ -119,7 +119,13 @@ function render($format, &$R, $data) { * Return path to the rendered image on our local system */ function _imgfile($data){ - $cache = $this->_cachename($data,'png'); + if ($this->getConf('path') && $this->getConf('svg')) { + $this->_format = 'svg'; + } else { + $this->_format = 'png'; + } + + $cache = $this->_cachename($data, $this->_format); // create the file if needed if(!file_exists($cache)){ @@ -135,7 +141,7 @@ function _imgfile($data){ // resized version if($data['width']){ - $cache = media_resize_image($cache,'png',$data['width'],$data['height']); + $cache = media_resize_image($cache,$this->_format,$data['width'],$data['height']); } // something went wrong, we're missing the file @@ -182,7 +188,7 @@ function _run($data,$in,$out) { } $cmd = $this->getConf('path'); - $cmd .= ' -Tpng'; + $cmd .= ' -T' . $this->_format; $cmd .= ' -K'.$data['layout']; $cmd .= ' -o'.escapeshellarg($out); //output $cmd .= ' '.escapeshellarg($in); //input