]> _ Git - cubeextranet.git/commitdiff
fix #4560 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Jun 2021 17:29:36 +0000 (17:29 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 28 Jun 2021 17:29:36 +0000 (17:29 +0000)
composer.json
inc/ws/Util/html5/twofaces/class.ws.html5.compiler.php

index e7f33660535b6d896598801b80879c47952720ea..f8bb31ba3a0fc9caec9e8b4543c758e5aa71068f 100644 (file)
@@ -3,6 +3,7 @@
     "php": ">=7.2",\r
     "php-mime-mail-parser/php-mime-mail-parser": "2.11.1",\r
     "jaybizzle/crawler-detect": "^1.2",\r
-    "ext-mbstring": "*"\r
+    "ext-mbstring": "*",\r
+    "ext-simplexml": "*"\r
   }\r
 }\r
index 23f38b0d9ab9cd6a0acfaa6f38c18e0163b4062a..a65986f97dfb122ea776bfd50c69d7c4d530fb03 100644 (file)
@@ -2668,9 +2668,35 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $dest = $dest;
         }
 
+        if (stripos($source, '.svg') !== false) {
+            $source = $this->_fixSVG($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 = CubeIT_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 addVideoJs()
     {
         $locale = $this->book->lang;