Skip to content

Commit

Permalink
Merge pull request #1538 from nowackipawel/patch-21
Browse files Browse the repository at this point in the history
WIP img fix(?) - html_helper
  • Loading branch information
lonnieezell authored Jan 3, 2019
2 parents 936f807 + a5b93ab commit bfc1569
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions system/Helpers/html_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ function img($src = '', bool $indexPage = false, $attributes = ''): string
$src = ['src' => $src];
}

//If there is no alt attribute defined, set it to an empty string.
if (! isset($src['alt']))
{
$src['alt'] = '';
$src['alt'] = $attributes['alt'] ?? '';
}


$img = '<img';

foreach ($src as $k => $v)
Expand All @@ -184,6 +184,12 @@ function img($src = '', bool $indexPage = false, $attributes = ''): string
}
}

// prevent passing "alt" to stringify_attributes
if(is_array($attributes) && isset($attributes['alt']))
{
unset($attributes['alt']);
}

return $img . stringify_attributes($attributes) . ' />';
}
}
Expand Down

0 comments on commit bfc1569

Please sign in to comment.