Skip to content
Snippets Groups Projects

Fix linking of SVGs in responsive image formatter

Merged Christopher Lewis requested to merge issue/svg_image-3485283:3485283-link-missing-on into 3.x
1 file
+ 20
7
Compare changes
  • Side-by-side
  • Inline
@@ -164,13 +164,26 @@ class SvgResponsiveImageFormatter extends ResponsiveImageFormatter {
$svgRaw = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $svgRaw);
$svgRaw = trim($svgRaw);
$elements[$delta] = [
'#markup' => Markup::create($svgRaw),
'#cache' => [
'tags' => $cacheTags,
'contexts' => $cacheContexts,
],
];
if ($url) {
$elements[$delta] = [
'#type' => 'link',
'#url' => $url,
'#title' => Markup::create($svgRaw),
'#cache' => [
'tags' => $cacheTags,
'contexts' => $cacheContexts,
],
];
}
else {
$elements[$delta] = [
'#markup' => Markup::create($svgRaw),
'#cache' => [
'tags' => $cacheTags,
'contexts' => $cacheContexts,
],
];
}
}
}
}
Loading