]> _ Git - fluidbook-toolbox.git/commitdiff
#7612 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Jun 2025 09:43:45 +0000 (11:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Jun 2025 09:43:45 +0000 (11:43 +0200)
app/Fluidbook/Compiler/Compiler.php

index 34550485db63ce7a9b7a30929f81eddb0b8414c6..8a528d3196de40eebd008ec2f873372fca1db993 100644 (file)
@@ -33,6 +33,7 @@ use Cubist\Util\Files\IVirtualDirectoryErrorListener;
 use Cubist\Util\Files\VirtualDirectory;
 use Cubist\Util\Graphics\Color;
 use Cubist\Util\Graphics\Image;
+use Cubist\Util\Graphics\Lottie;
 use Cubist\Util\PHP;
 use Cubist\Util\Text;
 use Cubist\Util\YoutubeDL;
@@ -1470,22 +1471,6 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
     }
 
 
-    public function addAudiodescription($link)
-    {
-
-        $e = explode('.', $link['to']);
-        $ext = mb_strtolower(array_pop($e));
-        if ($ext === 'txt') {
-            $file = $this->wdir . '/' . $link['to'];
-            if (file_exists($file)) {
-                $this->audioDescriptionTextsList[$link['page']] = ['text' => file_get_contents($file)];
-            }
-        } else {
-            $this->config->set('audiodescription.' . $link['page'], $link['to']);
-            $this->copyLinkFile($link['to'], 'data/audiodescription/');
-        }
-    }
-
     protected function beforeWriteConfig()
     {
         // Dynamic background
@@ -1786,12 +1771,12 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
 
     public function getWidth($page = 1)
     {
-        return $this->getPageDimension($page)[0] ??null;
+        return $this->getPageDimension($page)[0] ?? null;
     }
 
     public function getHeight($page = 1)
     {
-        return $this->getPageDimension($page)[1] ??null;
+        return $this->getPageDimension($page)[1] ?? null;
     }
 
 
@@ -2494,26 +2479,30 @@ class Compiler extends Base implements CompilerInterface, IVirtualDirectoryError
             return null;
         }
 
-
         if (file_exists($d . '/index.html')) {
-            $doc = new DOMDocument();
-            @$doc->loadHTMLFile($d . '/index.html');
-            $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'));
-            }
+            if ($lottie = Lottie::getAnimationDataFromHTMLFile($d . '/index.html')) {
+                $res['width'] = $lottie['w'];
+                $res['height'] = $lottie['h'];
+            } else {
+                $doc = new DOMDocument();
+                @$doc->loadHTMLFile($d . '/index.html');
+                $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="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'));
+                $m = $xpath->query('//meta[@name="height"]');
+                foreach ($m as $meta) {
+                    $res['height'] = intval((string)$meta->getAttribute('content'));
+                }
             }
 
             $r = array('html' => 'index.html', 'inject' => [], 'injectcss' => [], 'injectjs' => []);