From: Vincent Vanwaelscappel Date: Wed, 25 Jun 2025 09:43:45 +0000 (+0200) Subject: #7612 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ae99b669efca1f2e9d07a57753572eab6fb20751;p=fluidbook-toolbox.git #7612 @0.5 --- diff --git a/app/Fluidbook/Compiler/Compiler.php b/app/Fluidbook/Compiler/Compiler.php index 34550485d..8a528d319 100644 --- a/app/Fluidbook/Compiler/Compiler.php +++ b/app/Fluidbook/Compiler/Compiler.php @@ -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' => []);