Skip to content

Commit

Permalink
Fix a regression with icons in dark mode (see #7019)
Browse files Browse the repository at this point in the history
Description
-----------

Fixes #7018 

#6982 reverted #6880 so the logic was reintroduced within the new getHtml method

Commits
-------

f1e57ff Set dark mode data-icons (fixes #7018)
15b8634 Adjust darkAttributes logic
  • Loading branch information
zoglo committed Mar 14, 2024
1 parent ab4782c commit 4a759e5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion core-bundle/contao/library/Contao/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,19 @@ public static function getHtml($src, $alt='', $attributes='')

if (str_contains($template, '{darkAttributes}'))
{
$darkAttributes = new HtmlAttributes($attributes);

foreach (array('data-icon', 'data-icon-disabled') as $icon)
{
if (isset($darkAttributes[$icon]))
{
$pathinfo = pathinfo($darkAttributes[$icon]);
$darkAttributes[$icon] = $pathinfo['filename'] . '--dark.' . $pathinfo['extension'];
}
}

$search[] = '{darkAttributes}';
$replace[] = (new HtmlAttributes($attributes))->mergeWith(array('class' => 'color-scheme--dark', 'loading' => 'lazy'))->toString();
$replace[] = $darkAttributes->mergeWith(array('class' => 'color-scheme--dark', 'loading' => 'lazy'))->toString();
}

if (str_contains($template, '{lightAttributes}'))
Expand Down

0 comments on commit 4a759e5

Please sign in to comment.