namespace Cubist\Util\Animations;
+use DOMDocument;
+use DOMElement;
+use DOMXPath;
+
class ZipAnimation extends OAMAnimation
{
public static function getZIPData($src)
$index = $unz . '/index.html';
if (file_exists($index)) {
$c = file_get_contents($index);
+ $res['html'] = $c;
if (stripos($c, '<div id="lottie"></div>') !== 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;