Skip to content

Commit d385267

Browse files
author
roadiz-ci
committed
chore: handle private and non-processable documents
1 parent b15e9e8 commit d385267

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/EntityThumbnail/Provider/DocumentThumbnailProvider.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ public function supports(string $entityClass, int|string $identifier): bool
3030

3131
public function getDocumentUrl(BaseDocumentInterface $document, int $size = 64): ?string
3232
{
33+
if ($document->isPrivate()) {
34+
return null;
35+
}
36+
37+
if (!$document->isProcessable()) {
38+
return $this->documentUrlGenerator
39+
->setDocument($document)
40+
->setOptions([
41+
'noProcess' => true,
42+
])
43+
->getUrl()
44+
;
45+
}
46+
3347
$url = $this->documentUrlGenerator
3448
->setDocument($document)
3549
->setOptions([
@@ -42,7 +56,7 @@ public function getDocumentUrl(BaseDocumentInterface $document, int $size = 64):
4256
->getUrl()
4357
;
4458

45-
if ($document->isProcessable() && !str_ends_with($url, '.webp')) {
59+
if (!str_ends_with($url, '.webp')) {
4660
$url .= '.webp';
4761
}
4862

0 commit comments

Comments
 (0)