From 38d75a78d58d0fdafc7c4f22e8a2179e4a379e20 Mon Sep 17 00:00:00 2001 From: Adam Weston Date: Tue, 7 Jan 2025 11:54:17 -0500 Subject: [PATCH] Fix: php image extension property exception --- src/Extensions/Nodes/Image.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Extensions/Nodes/Image.php b/src/Extensions/Nodes/Image.php index e960c18..d706734 100644 --- a/src/Extensions/Nodes/Image.php +++ b/src/Extensions/Nodes/Image.php @@ -44,7 +44,13 @@ public function addAttributes(): array 'media' => [ 'default' => null, 'parseHTML' => fn ($DOMNode) => $DOMNode->getAttribute('data-media-id') ?: null, - 'renderHTML' => fn ($attributes) => $attributes->media ? ['data-media-id' => $attributes->media] : null, + 'renderHTML' => function ($attributes) { + if (! property_exists($attributes, 'media')) { + return null; + } + + return ['data-media-id' => $attributes->media]; + }, ], ]; }