-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Would be great if the package supports flexible resizing, effects etc. through url parameters. This can "almost" be done, but the image cache does not support this:
In short:
Issue: ImageCache does not support url parameters, but takes only filename as cache key
possible solutions:
- allow to configure custom implementation of ImageCache
- allow to pass cache key parameters through
applyFilter()method
working example for 'dynamic' filter:
public function applyFilter(Image $image)
{
// issue:
// parameter is not added to cachekey
// w = width in px
$width =request()->input('w');
$quality =request()->input('q') ?? 90;
$image->resize($width, null, function ($constraint) {
$constraint->aspectRatio();
})
->encode('jpg', $quality)
;
return $image;
}
example requests:
- generate thumbnail:
http://yourhost.com/{route-name}/original/{file-name}?w=100&q=50
- generate preview:
http://yourhost.com/{route-name}/original/{file-name}?w=200&q=90
both urls will return the same cached image (whichever was called first) as the cache key does not support parameters.
Metadata
Metadata
Assignees
Labels
No labels