diff --git a/components/Attachment/Entity/Attachment.php b/components/Attachment/Entity/Attachment.php index bd648c5367..567e3002e6 100644 --- a/components/Attachment/Entity/Attachment.php +++ b/components/Attachment/Entity/Attachment.php @@ -357,7 +357,7 @@ class Attachment extends Entity * * @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); } diff --git a/plugins/Embed/Entity/AttachmentEmbed.php b/plugins/Embed/Entity/AttachmentEmbed.php index 474bd92f67..b87cf2c09e 100644 --- a/plugins/Embed/Entity/AttachmentEmbed.php +++ b/plugins/Embed/Entity/AttachmentEmbed.php @@ -185,10 +185,10 @@ class AttachmentEmbed extends Entity $thumbnail = $attachment->getThumbnail('medium'); if (\is_null($attachment) || \is_null($attachment->getWidth()) || \is_null($attachment->getHeight())) { $attr['has_attachment'] = false; - } else { + } elseif (!\is_null($thumbnail)) { $attr['has_attachment'] = true; - $attr['width'] = $thumbnail->getWidth(); - $attr['height'] = $thumbnail->getHeight(); + $attr['width'] = $thumbnail->getWidth(); + $attr['height'] = $thumbnail->getHeight(); } return $attr; }