Skip to content

Commit

Permalink
Apply glide params to src image
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Oct 9, 2024
1 parent 87e4203 commit 5a1589c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Tags/ResponsiveTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public function index()
$width = $dimensions->getWidth();
$height = $dimensions->getHeight();

$src = app(GenerateImageJob::class, ['asset' => $responsive->asset, 'params' => [
'width' => $width,
'height' => $height,
]])->handle();
$src = app(GenerateImageJob::class, [
'asset' => $responsive->asset,
'params' => array_merge($this->getGlideParams(), ['width' => $width, 'height' => $height]),
])->handle();

$includePlaceholder = $this->includePlaceholder();

Expand All @@ -82,6 +82,14 @@ public function index()
])->render();
}

private function getGlideParams(): array
{
return collect($this->params)
->reject(fn ($value, $name) => ! str_starts_with($name, 'glide:'))
->mapWithKeys(fn ($value, $name) => [str_replace('glide:', '', $name) => $value])
->toArray();
}

private function getAttributeString(): string
{
$breakpointPrefixes = collect(array_keys(config('statamic.responsive-images.breakpoints')))
Expand Down

0 comments on commit 5a1589c

Please sign in to comment.