Skip to content

Commit 9b76887

Browse files
author
roadiz-ci
committed
chore(DocumentExplorerItem): check if Document is Sizeable to get its image size
1 parent 63417d1 commit 9b76887

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/Explorer/DocumentExplorerItem.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use RZ\Roadiz\Documents\Models\AdvancedDocumentInterface;
1212
use RZ\Roadiz\Documents\Models\DocumentInterface;
1313
use RZ\Roadiz\Documents\Models\HasThumbnailInterface;
14+
use RZ\Roadiz\Documents\Models\SizeableInterface;
1415
use RZ\Roadiz\Documents\Renderer\RendererInterface;
1516
use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface;
1617
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -139,8 +140,11 @@ public function toArray(): array
139140
$thumbnail80Url = $this->documentUrlGenerator->getUrl();
140141
$this->documentUrlGenerator->setOptions($previewOptions);
141142
$editImageUrl = $this->documentUrlGenerator->getUrl();
142-
$editImageWidth = $this->document->getImageWidth();
143-
$editImageHeight = $this->document->getImageHeight();
143+
144+
if ($this->document instanceof SizeableInterface) {
145+
$editImageWidth = $this->document->getImageWidth();
146+
$editImageHeight = $this->document->getImageHeight();
147+
}
144148
}
145149

146150
$embedFinder = $this->embedFinderFactory?->createForPlatform(
@@ -171,8 +175,8 @@ public function toArray(): array
171175
'shortMimeType' => $this->document->getShortMimeType(),
172176
'thumbnail80' => $thumbnail80Url,
173177
'editImageUrl' => $editImageUrl,
174-
'editImageWidth' => $editImageWidth,
175-
'editImageHeight' => $editImageHeight,
178+
'editImageWidth' => $editImageWidth ?? null,
179+
'editImageHeight' => $editImageHeight ?? null,
176180
'originalHotspot' => $originalHotspot ?? null,
177181
];
178182
}

0 commit comments

Comments
 (0)