return $this->getWidth() * $this->getHeight();
}
- public function getWidth() {
- return $this->getSourceOfPage(1)->getSource()->getDocument()->getWidth();
+ public function getWidth($page = 1) {
+ return $this->getSourceOfPage($page)->getSource()->getDocument()->getWidth();
}
- public function getHeight() {
- return $this->getSourceOfPage(1)->getSource()->getDocument()->getHeight();
+ public function getHeight($page = 1) {
+ return $this->getSourceOfPage($page)->getSource()->getDocument()->getHeight();
}
public function addVideoJs() {
// TODO: Implement pushSetting() method.
}
- public function getWidthForLinks() {
+ public function getWidthForLinks($page = 1) {
return $this->getWidth() / $this->getLinkScale();
}
- public function getHeightForLinks() {
- return $this->getHeight() / $this->getLinkScale();
+ public function getHeightForLinks($page = 1) {
+ return $this->getHeight($page) / $this->getLinkScale();
}
public function page_path($page, $path = ''): string;
- public function getWidth();
+ public function getWidth($page = 1);
- public function getWidthForLinks();
+ public function getWidthForLinks($page = 1);
- public function getHeight();
+ public function getHeight($page = 1);
- public function getHeightForLinks();
+ public function getHeightForLinks($page = 1);
public function virtualToPhysical($virtual);
public function getPageNumber(): int;
- public function getQuality():int;
+ public function getQuality(): int;
}
// TODO: Implement addSEOArticle() method.
}
- public function getWidthForLinks() {
+ public function getWidthForLinks($page=1) {
// TODO: Implement getWidthForLinks() method.
}
- public function getHeightForLinks() {
+ public function getHeightForLinks($page=1) {
// TODO: Implement getHeightForLinks() method.
}
public function getAdditionnalContent() {
$res = parent::getAdditionnalContent();
if ($this->allowsAnimation) {
- $animations = self::parseAnimations($this->image_rollover);
+ $animations = self::parseAnimations($this->image_rollover ?? 'none');
foreach ($animations as $animation) {
if (isset($animation['blendmode'])) {
$this->blendmode = $animation['blendmode'];
$this->addzindex = $animation['addzindex'];
}
}
- if($animations) {
+ if ($animations) {
$res .= ' data-animations="' . htmlspecialchars(json_encode($animations), ENT_QUOTES) . '" ';
if ($this->_isHiddenFirst($animations)) {
$res .= ' data-animation-hide ';
namespace Fluidbook\Tools\Links;
-class ImageLink extends ContentLink
-{
+class ImageLink extends ContentLink {
- public function getImageUrl()
- {
+ public function getImageUrl() {
return Link::getUniversalLocation($this->to, false);
}
- public function getCSS()
- {
+ public function getCSS() {
$res = parent::getCSS();
$this->copyExternalFile($this->to);
return $res;
}
- public function getAdditionnalContent()
- {
+ public function getAdditionnalContent() {
$res = parent::getAdditionnalContent();
$res .= ' data-image="' . $this->getImageUrl() . '"';
- $res .= ' data-rollover="' . $this->image_rollover . '"';
+ if (isset($this->image_rollover)) {
+ $res .= ' data-rollover="' . $this->image_rollover . '"';
+ }
return $res;
}
- public function getHTMLContent()
- {
+ public function getHTMLContent() {
// For zoomin & zoomout animations
- if (stristr($this->image_rollover, 'type=zoom')) {
+ if (isset($this->image_rollover) && stristr($this->image_rollover, 'type=zoom')) {
return '<div class="img" style="background-image:url(' . $this->getImageUrl() . ');"></div>';
} else {
return '<img src="' . $this->getImageUrl() . '" />';
$a[$k] = floatval($v);
}
}
+ if ($a['width'] < 0) {
+ $a['left'] += $a['width'];
+ $a['width'] *= -1;
+ }
+ if ($a['height'] < 0) {
+ $a['top'] += $a['height'];
+ $a['height'] *= -1;
+ }
}
public function getSurface() {
use Cubist\Util\Text;
use Fluidbook\Tools\Compiler\CompilerInterface;
use Fluidbook\Tools\SVG\SVGTools;
+use Illuminate\Support\Facades\Log;
class ZoomLink extends NormalLink {
protected $maxzoom_default = 2;
$extractPage = $attributes['page'];
}
+ $extractOptions['texts'] = true;
+ $extractOptions['background'] = true;
+
$extractOptions['format'] = 'jpeg';
$ext = 'jpg';
if (isset($attributes['layer'])) {
$cache = $compiler->getCacheDir("zoomarea/" . $cachedir);
- $leftHeight = min($h, $compiler->getHeightForLinks() - $y);
- $leftWidth = min($w, $compiler->getWidthForLinks() - $x);
+ $leftHeight = min($h, $compiler->getHeightForLinks($attributes['page']) - $y);
+ $leftWidth = min($w, $compiler->getWidthForLinks($attributes['page']) - $x);
$leftArea = ['x' => $x, 'y' => $y, 'width' => $leftWidth, 'height' => $leftHeight];
$extractPage,
$leftArea,
null, $extractOptions, $cache);
+ if (!file_exists($leftfile)) {
+ throw new \Exception('Failed to generate image with ' . json_encode($attributes));
+ }
if ($attributes['page'] % 2 === 0 && ($x + $w) > ($bookwidth + 1) && $compiler->isDoublePage() && $attributes['page'] + 1 <= $compiler->getPageNumber()) {
if (!isset($attributes['pdf']) || !$attributes['pdf']) {
// dd($both);
+ if (!file_exists($both)) {
+ Log::error('Failed generate image ' . json_encode($attributes));
+ }
$dest = 'data/links/' . $save . '_' . $attributes['id'] . '.' . $ext;
$compiler->simpleCopyLinkFile($both, $dest);
}