Skip to content

Commit

Permalink
fix: Fixed an issue where the .imgTag() and .pictureTag() would o…
Browse files Browse the repository at this point in the history
…utput and invalid `style` attribute for lazy loaded images ([#400](#400))
  • Loading branch information
khalwat committed May 9, 2024
1 parent cf5ab7c commit 11f439d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/models/BaseImageTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ protected function swapLazyLoadAttrs(string $loading, string $placeHolder, array
}
// Set the style on this element to be the placeholder image as the background-image
if (isset($attrs['style']) && !empty($attrs['src'])) {
$attrs['style'] = trim(
$attrs['style'] .
'background-image:url(' . $this->getLazyLoadSrc($placeHolder) . '); background-size: cover;'
);
if (empty($attrs['style'])) {
$attrs['style'] = [];
}
$attrs['style']['background-image'] = 'url(' . $this->getLazyLoadSrc($placeHolder) . ')';
$attrs['style']['background-size'] = 'cover';
}
// Handle attributes that lazy and lazySizesFallback have in common
switch ($loading) {
Expand Down

0 comments on commit 11f439d

Please sign in to comment.