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;
}
- 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
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;
}
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' => []);