From: Vincent Vanwaelscappel Date: Mon, 22 May 2023 13:30:40 +0000 (+0200) Subject: wip #5936 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=6f432d11014371bbb1bcdf906755a9a11ba37532;p=fluidbook_tools.git wip #5936 --- diff --git a/src/Compiler/Links.php b/src/Compiler/Links.php index 2518c08..1bdba83 100644 --- a/src/Compiler/Links.php +++ b/src/Compiler/Links.php @@ -371,33 +371,12 @@ trait Links { } if (stripos($source, '.svg') !== false) { - $source = $this->_fixSVG($source); + $source = \Cubist\Util\Graphics\Image::fixSVGDimensions($source); } $this->vdir->copy($source, $dest); } - protected function _fixSVG($source) { - $fixed = str_replace('.svg', '.f.svg', $source); - if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) { - return $fixed; - } - $svg = simplexml_load_string(file_get_contents($source)); - $attr = $svg->attributes(); - if (isset($attr['width'], $attr['height'])) { - copy($source, $fixed); - return $fixed; - } - - $dim = Image::getimagesize($source); - $svg->addAttribute('preserveAspectRatio', 'none'); - $svg->addAttribute('width', $dim[0]); - $svg->addAttribute('height', $dim[1]); - file_put_contents($fixed, $svg->asXML()); - - return $fixed; - } - public function getVideosFormats() { return ['mp4', 'jpg']; }