]> _ Git - fluidbook_tools.git/commitdiff
wip #5936
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 May 2023 13:30:40 +0000 (15:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 22 May 2023 13:30:40 +0000 (15:30 +0200)
src/Compiler/Links.php

index 2518c081a6144fd13caadecf26a36e5dc28090ef..1bdba83964180a6febaa77e9dfd5ad9e3d029b9b 100644 (file)
@@ -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'];
     }