diff --git a/src/Tags/ResponsiveTag.php b/src/Tags/ResponsiveTag.php index 4aae72c..269cef4 100644 --- a/src/Tags/ResponsiveTag.php +++ b/src/Tags/ResponsiveTag.php @@ -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(); @@ -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'))) diff --git a/tests/__snapshots__/ResponsiveTagTest__it_can_add_custom_glide_parameters__1.txt b/tests/__snapshots__/ResponsiveTagTest__it_can_add_custom_glide_parameters__1.txt index 49b16e6..7da05ec 100644 --- a/tests/__snapshots__/ResponsiveTagTest__it_can_add_custom_glide_parameters__1.txt +++ b/tests/__snapshots__/ResponsiveTagTest__it_can_add_custom_glide_parameters__1.txt @@ -28,7 +28,7 @@ test.jpg