From: Harvie Date: Sun, 20 Jun 2010 02:11:53 +0000 (+0200) Subject: autodetection of image size for stupid browsers X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=3955ca30c20849a706a237b609d65c281ec3118e;p=mirrors%2FDokuWiki-Plugin-SVGEdit.git autodetection of image size for stupid browsers --- diff --git a/syntax.php b/syntax.php index 442d45f..f814a32 100755 --- a/syntax.php +++ b/syntax.php @@ -52,28 +52,36 @@ class syntax_plugin_svgedit extends DokuWiki_Syntax_Plugin { if ($format!='xhtml') return; global $ID; - $is_webkit= preg_match('/webkit/', strtolower($_SERVER['HTTP_USER_AGENT']) ); // dirty, but fast /n3k/ + $svg_wiki_page = trim(substr($data[1], 6, -2)); //name of wiki page containing SVG image + + //detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size) + $svg_dimensions = ''; + preg_match('/width="[0-9]+" height="[0-9]+"/', rawWiki($svg_wiki_page), $_); + if(isset($_[0])) $svg_dimensions = $_[0]; + + //use object tag for stupid browsers (like firefox) - ugly (relies on browser identification) + $is_webkit= preg_match('/webkit/', strtolower($_SERVER['HTTP_USER_AGENT'])); if ($is_webkit) $svgtag=''.$svgtag.$svgenc.'" alt="svg-image@'.$ID.'" />'."
"; return true; } if($data[0]==='{{sv') { - $data[1] = trim(substr($data[1], 6, -2)); - $svgenc = exportlink($data[1],'svg'); - $renderer->doc .= ''.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($data[1]).'" type="image/svg+xml"/>
'; - $renderer->doc .= html_wikilink($data[1],'svg@'.$data[1]); + $svgenc = exportlink($svg_wiki_page,'svg'); + $renderer->doc .= ''.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" type="image/svg+xml"/>
'; + $renderer->doc .= html_wikilink($svg_wiki_page,'svg@'.$svg_wiki_page); return true; } if($data[0]==='{{SV') { - $data[1] = trim(substr($data[1], 6, -2)); - $svgenc = 'data:image/svg+xml;base64,'.base64_encode(rawWiki($data[1])).'" type="image/svg+xml'; - $renderer->doc .= ''.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($data[1]).'" />
'; - $renderer->doc .= html_wikilink($data[1],'SVG@'.$data[1]); + $svgenc = 'data:image/svg+xml;base64,'.base64_encode(rawWiki($svg_wiki_page)).'" type="image/svg+xml'; + $renderer->doc .= ''.$svgtag.$svgenc.'" alt="image:'.htmlspecialchars($svg_wiki_page).'" />
'; + $renderer->doc .= html_wikilink($svg_wiki_page,'SVG@'.$svg_wiki_page); return true; } }