Microweber\Providers\MediaManager::svgScaleHack PHP Method

svgScaleHack() private method

private svgScaleHack ( $svg, $minWidth, $minHeight )
    private function svgScaleHack($svg, $minWidth, $minHeight)
    {
        $reW = '/(.*<svg[^>]* width=")([\\d.]+px)(.*)/si';
        $reH = '/(.*<svg[^>]* height=")([\\d.]+px)(.*)/si';
        preg_match($reW, $svg, $mw);
        preg_match($reH, $svg, $mh);
        if (!isset($mw[2]) and isset($mh[2])) {
            $mw[2] = $mh[2];
        }
        if (empty($mw)) {
            $width = floatval($minWidth);
            $height = floatval($minHeight);
        } else {
            $width = floatval($mw[2]);
            $height = floatval($mh[2]);
        }
        if (!$width || !$height) {
            return false;
        }
        // scale to make width and height big enough
        $scale = 1;
        if ($width < $minWidth) {
            $scale = $minWidth / $width;
        }
        if ($height < $minHeight) {
            $scale = max($scale, $minHeight / $height);
        }
        $scale = 1;
        $svg = preg_replace($reW, "\${1}{$width}px\${3}", $svg);
        $svg = preg_replace($reH, "\${1}{$height}px\${3}", $svg);
        return $svg;
    }