From abedfb4124d7380dc1e400fbbc360cdb158f11bc Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 30 Jun 2023 11:27:38 +0200 Subject: [PATCH] wait #6097 @0.5 --- src/Animations/ZipAnimation.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Animations/ZipAnimation.php b/src/Animations/ZipAnimation.php index 7fc15e9..5e27832 100644 --- a/src/Animations/ZipAnimation.php +++ b/src/Animations/ZipAnimation.php @@ -2,6 +2,10 @@ namespace Cubist\Util\Animations; +use DOMDocument; +use DOMElement; +use DOMXPath; + class ZipAnimation extends OAMAnimation { public static function getZIPData($src) @@ -10,12 +14,32 @@ class ZipAnimation extends OAMAnimation $index = $unz . '/index.html'; if (file_exists($index)) { $c = file_get_contents($index); + $res['html'] = $c; if (stripos($c, '
') !== false) { preg_match('/var animationData = (\{.*\})/', $c, $m); $ad = json_decode(trim($m[1]), true); $res['width'] = $ad['w']; $res['height'] = $ad['h']; + } else { + $doc = new DOMDocument(); + @$doc->loadHTML($c); + $xpath = new DOMXPath($doc); + $c = $xpath->query("//canvas"); + foreach ($c as $canvas) { + /* @var $canvas DOMElement */ + $res['width'] = intval((string)$canvas->getAttribute('width')); + $res['height'] = intval((string)$canvas->getAttribute('height')); + } + + $m = $xpath->query('//meta[@name="width"]'); + foreach ($m as $meta) { + $res['width'] = intval((string)$meta->getAttribute('content')); + } + $m = $xpath->query('//meta[@name="height"]'); + foreach ($m as $meta) { + $res['height'] = intval((string)$meta->getAttribute('content')); + } } $res['path'] = $unz; return $res; -- 2.39.5