Skip to content

Commit

Permalink
feat: allow image lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphjsmit committed Nov 1, 2023
1 parent 6fbed51 commit c0b9594
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/GlideImageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

class GlideImageGenerator
{
public function src(string $path, int $maxWidth = null, string $sizes = null): ComponentAttributeBag
public function src(string $path, int $maxWidth = null, string $sizes = null, bool $lazy = true): ComponentAttributeBag
{
$attributes = new ComponentAttributeBag();

$attributes->setAttributes([
'src' => $this->getSrcAttribute($path, $maxWidth),
'srcset' => $this->getSrcsetAttribute($path, $maxWidth),
...$sizes !== null ? ['sizes' => $sizes] : [],
...$lazy ? ['loading' => 'lazy'] : [],
]);

return $attributes;
Expand Down

0 comments on commit c0b9594

Please sign in to comment.