{{svg}} action

 

Save the following code as (plugins/)actions/svg.php.
<?php
/**
 * Include svg files into a page.
 *
 * Syntax: {{svg url="http://example.com/example.svg" [width="x"] [height="x"]}}
 *
 * Width and Height are optional arguments.
 *
 * @uses    Wakka::cleanUrl()
 */


// setting defaults
$width = 550;
$height = 400;
$url = '';

// getting params
if (is_array($vars))
{
    foreach ($vars as $param => $value)
    {
        if ($param == 'width')
        {
            $width = (int)$vars['width'];
            if ($width>950) $width = 950;
        }
        if ($param == 'height')
        {
            $height = (int)$vars['height'];
            if ($height>950) $height = 950;
        }
        if ($param == 'url')
        {
            $url = $this->cleanUrl(trim($vars['url']));
        }
       
    }
}

// compatibilty for {{svg http://example.com/example.svg}}
if ('' == $url && isset($wikka_vars)) $url = $this->cleanUrl(trim($wikka_vars));

// ouput, if any
if ('' != $url)
  echo '<object data="'.$url.'" width="'.$width.'" height="'.$height.'">'.
'</object>';
?>

 

CategoryUserContributions
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki