]> _ Git - fluidbook_tools.git/commitdiff
wait #6753 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 27 Feb 2024 11:27:01 +0000 (12:27 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 27 Feb 2024 11:27:01 +0000 (12:27 +0100)
src/SVG/SVGTools.php

index c8cdaf82f34b7e2c25a079d3da5cd8271d56c373..ec9609b5e89b09533002a70006f7a1e99317a25a 100644 (file)
@@ -90,7 +90,7 @@ class SVGTools
 
     public static function addDimensionsAttributes($in)
     {
-        if (!strstr($in, '<svg') && file_exists($in)) {
+        if (!str_contains($in, '<svg') && file_exists($in)) {
             $in = file_get_contents($in);
         }
         try {
@@ -105,11 +105,26 @@ class SVGTools
                 if (!isset($attr['height'])) {
                     $xmlsvg->addAttribute('height', (float)$e[3]);
                 }
-                return preg_replace('\<\?xml.*\?\>', '', $xmlsvg->asXML());
+                $in = $xmlsvg->asXML();
             }
         } catch (\Exception $e) {
-
+            Log::warning($e->getMessage());
         }
+        return $in;
+    }
+
+    public static function removeXMLDeclaration($in)
+    {
+        return trim(preg_replace('/\<\?xml.*\?\>/', '', $in));
+    }
+
+    public static function removeXMLComments($in)
+    {
+        return trim(preg_replace('/\<!--.*--\>/', '', $in));
+    }
+
+    public static function disablePreserveRatio($in)
+    {
         return self::_disablePreserveRatio($in);
     }