From c78d5adb40ce92f694617547cabd2fe6689bda8c Mon Sep 17 00:00:00 2001 From: loma-one <44441246+loma-one@users.noreply.github.com> Date: Fri, 6 Mar 2026 21:20:54 +0100 Subject: [PATCH 1/4] Refactor image link generation in BBCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, images embedded in continuous text were opened with the attribute `target=’_blank‘`. However, they should be loaded and displayed in the Fancybox. As a result of the change, images are now loaded in the Fancybox. Links and videos are identified in order to maintain the previous functionality. --- src/Content/Text/BBCode.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 6634e2202c..15e7b0da9d 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -473,14 +473,19 @@ class BBCode if (!empty($data['title']) && !empty($data['url'])) { $preview_class = in_array($preview_mode, [self::PREVIEW_AUTO, self::PREVIEW_LARGE]) ? 'attachment-image' : 'attachment-preview'; - if (!empty($data['image']) && empty($data['text']) && ($data['type'] == 'photo')) { - $return .= sprintf('', $data['url'], self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title']); + + $is_photo = ($data['type'] === 'photo'); + $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer"'; + + if (!empty($data['image']) && empty($data['text']) && $is_photo) { + $return .= sprintf('', $data['url'], $link_attributes, self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title'], $preview_class); } else { if (!empty($data['image'])) { - $return .= sprintf('
', $data['url'], self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title']); + $return .= sprintf('
', $data['url'], $link_attributes, self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title'], $preview_class); } elseif (!empty($data['preview'])) { - $return .= sprintf('
', $data['url'], self::proxyUrl($data['preview'], $simplehtml, $uriid), $data['title']); + $return .= sprintf('
', $data['url'], $link_attributes, self::proxyUrl($data['preview'], $simplehtml, $uriid), $data['title']); } + $return .= sprintf('

%s

', $data['url'], $data['title']); } } From ecd432c4138ac0c1c3144bb776756ac80a3ba5bd Mon Sep 17 00:00:00 2001 From: loma-one <44441246+loma-one@users.noreply.github.com> Date: Thu, 12 Mar 2026 09:45:36 +0100 Subject: [PATCH 2/4] Fix link attributes formatting in BBCode.php --- src/Content/Text/BBCode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 15e7b0da9d..48c0098443 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -475,7 +475,7 @@ class BBCode $preview_class = in_array($preview_mode, [self::PREVIEW_AUTO, self::PREVIEW_LARGE]) ? 'attachment-image' : 'attachment-preview'; $is_photo = ($data['type'] === 'photo'); - $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer"'; + $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer'; if (!empty($data['image']) && empty($data['text']) && $is_photo) { $return .= sprintf('', $data['url'], $link_attributes, self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title'], $preview_class); From 2ac2000a110eb2193f0c4a273a5c9970bc8ee3ee Mon Sep 17 00:00:00 2001 From: loma-one <44441246+loma-one@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:30:06 +0100 Subject: [PATCH 3/4] Fix link attributes assignment for photo previews --- src/Content/Text/BBCode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 48c0098443..15e7b0da9d 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -475,7 +475,7 @@ class BBCode $preview_class = in_array($preview_mode, [self::PREVIEW_AUTO, self::PREVIEW_LARGE]) ? 'attachment-image' : 'attachment-preview'; $is_photo = ($data['type'] === 'photo'); - $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer'; + $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer"'; if (!empty($data['image']) && empty($data['text']) && $is_photo) { $return .= sprintf('', $data['url'], $link_attributes, self::proxyUrl($data['image'], $simplehtml, $uriid), $data['title'], $preview_class); From 1e26082fcc1b9c4d323f0c55b14b084b46bd1b9c Mon Sep 17 00:00:00 2001 From: loma-one <44441246+loma-one@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:37:52 +0100 Subject: [PATCH 4/4] Fix indentation for is_photo variable assignment --- src/Content/Text/BBCode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index 15e7b0da9d..b7e6f334ab 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -474,7 +474,7 @@ class BBCode if (!empty($data['title']) && !empty($data['url'])) { $preview_class = in_array($preview_mode, [self::PREVIEW_AUTO, self::PREVIEW_LARGE]) ? 'attachment-image' : 'attachment-preview'; - $is_photo = ($data['type'] === 'photo'); + $is_photo = ($data['type'] === 'photo'); $link_attributes = $is_photo ? 'data-fancybox="gallery" rel="noopener noreferrer"' : 'target="_blank" rel="noopener noreferrer"'; if (!empty($data['image']) && empty($data['text']) && $is_photo) {