[COMPONENT][Attachment][Entity][Attachment] getThumbnail can be null

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-02 21:24:51 +00:00
parent 2967b544f5
commit bfec10fc95
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 4 additions and 4 deletions

View File

@ -357,7 +357,7 @@ class Attachment extends Entity
* *
* @return AttachmentThumbnail * @return AttachmentThumbnail
*/ */
public function getThumbnail(?string $size = null, bool $crop = false): AttachmentThumbnail public function getThumbnail(?string $size = null, bool $crop = false): ?AttachmentThumbnail
{ {
return AttachmentThumbnail::getOrCreate(attachment: $this, size: $size, crop: $crop); return AttachmentThumbnail::getOrCreate(attachment: $this, size: $size, crop: $crop);
} }

View File

@ -185,10 +185,10 @@ class AttachmentEmbed extends Entity
$thumbnail = $attachment->getThumbnail('medium'); $thumbnail = $attachment->getThumbnail('medium');
if (\is_null($attachment) || \is_null($attachment->getWidth()) || \is_null($attachment->getHeight())) { if (\is_null($attachment) || \is_null($attachment->getWidth()) || \is_null($attachment->getHeight())) {
$attr['has_attachment'] = false; $attr['has_attachment'] = false;
} else { } elseif (!\is_null($thumbnail)) {
$attr['has_attachment'] = true; $attr['has_attachment'] = true;
$attr['width'] = $thumbnail->getWidth(); $attr['width'] = $thumbnail->getWidth();
$attr['height'] = $thumbnail->getHeight(); $attr['height'] = $thumbnail->getHeight();
} }
return $attr; return $attr;
} }