]> _ Git - cubist_util.git/commitdiff
wip #5776 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Mar 2023 18:34:36 +0000 (19:34 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Mar 2023 18:34:36 +0000 (19:34 +0100)
src/Graphics/Image.php

index 404655719b3372a491014df7602676a1ecad8ded..4c3c1e4834243e35e19da0be382b8b610a83a771 100644 (file)
@@ -24,7 +24,7 @@ class Image
             throw new \Exception('File ' . $path . ' does not exist');
         }
 
-        $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm', 'pdf'];
+        $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm', 'pdf', 'html'];
 
         $ext = Files::getExtension($path);
         if (!in_array($ext, $allowedExtensions)) {
@@ -55,6 +55,14 @@ class Image
         } else if ($ext === 'zip') {
             $zip = ZipAnimation::getZIPData($path);
             $res = [$zip['width'], $zip['height']];
+        } else if ($ext === 'html') {
+            $htmlContent = file_get_contents($path);
+            if (stristr($htmlContent, '<div id="lottie"></div>')) {
+                if (preg_match('/var animationData = (\{.*\})/', $htmlContent, $m)) {
+                    $ad = json_decode(trim($m[1]), true);
+                    $res = [$ad['w'], $ad['h']];
+                }
+            }
         } else {
             $res = getimagesize($path);
         }