From 7f93e61a2c27507e208de21cd80a7ec831bf1db4 Mon Sep 17 00:00:00 2001 From: indigoxela Date: Thu, 7 Mar 2024 20:41:35 +0100 Subject: [PATCH] Issue #6384: Make alignment of linked captioned images work regardless of filter order. By @indigoxela, @herbdool, and @olafgrabienski. --- core/modules/filter/filter.module | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 8e46359941..94dce3c8b0 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -2670,6 +2670,11 @@ function _filter_image_align($text) { if ($parent && $parent->nodeName === 'figure') { $target = $parent; } + // Consider more deeply nested structures. A link wrapped around a + // captioned image. + elseif ($parent && $parent->nodeName === 'a' && $parent->parentNode && $parent->parentNode->nodeName === 'figure') { + $target = $parent->parentNode; + } else { $target = $node; }