Skip to content

Commit

Permalink
add check for the src tag
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-24 committed Apr 30, 2020
1 parent 314ec6a commit 2500b99
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion imagelazyloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function onContentPrepare($context, &$row, &$params, $page = 0)

foreach ($matches[0] as $image)
{
if (strpos($image, ' loading=') === false)
// Make sure we have a src but no loading attribute
if (strpos($image, ' src=') !== false && strpos($image, ' loading=') === false)
{
$lazyloadImage = str_replace('<img ', '<img loading="lazy" ', $image);
$row->text = str_replace($image, $lazyloadImage, $row->text);
Expand Down

0 comments on commit 2500b99

Please sign in to comment.