From 8b0d40f13a0952381d8d7df3057614283d070aed Mon Sep 17 00:00:00 2001 From: Steve Ross Date: Thu, 5 Feb 2026 20:45:54 +0000 Subject: [PATCH] core/image: only output
rather than complete html document --- app/blocks.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/blocks.php b/app/blocks.php index 3f42f28e..0f96a985 100644 --- a/app/blocks.php +++ b/app/blocks.php @@ -268,14 +268,19 @@ function core_details_modified($content, $block) function core_image_modified($content, $block) { - $imageID = @$block['attrs']['id']; - $lazy = wp_get_attachment_image_src($imageID, 'lazy'); - $large = wp_get_attachment_image_src($imageID, '2048x2048'); - $dom = new \DomDocument(); $dom->strictErrorChecking = false; @$dom->loadHTML($content); - @$images = $dom->getElementsByTagName('img'); + + $images = @$dom->getElementsByTagName('img'); + $figures = @$dom->getElementsByTagName('figure'); + + if(!$figures) return $content; + + // get image data + $imageID = @$block['attrs']['id']; + $lazy = wp_get_attachment_image_src($imageID, 'lazy'); + $large = wp_get_attachment_image_src($imageID, '2048x2048'); // create lightbox link node $link = $dom->createElement('a'); @@ -311,5 +316,6 @@ function core_image_modified($content, $block) $linkClone->appendChild($image); } - return $dom->saveHTML(); + return $dom->saveHTML($figures[0]); + }