Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ This will **empty the entire Glide cache**. You can choose to put this in your d

## Glide Configuration

Currently, the package **does not provide configuration** options and it just assumes **sensible defaults**.
Currently, the package **does not provide advanced configuration** options and it just assumes **sensible defaults**.

If you want to modify the basic configuration values, you can publish the config file:

```bash
php artisan vendor:publish --tag=glide-config
```

After publishing, you can modify the configuration in `config/glide.php`.

Since it is geared at auto-generating versions for static images, it will **assume** the `public_path()`/`asset()` as root folder for the images.

Expand Down
38 changes: 23 additions & 15 deletions config/glide.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@
*/
'default_source_disk' => null,

'route' => [
/**
* The domain that will be used to generate the Glide URLs.
*/
'domain' => null,

/**
* Whether the generated Glide URLs should be signed.
* For some browsers this differing query string
* might prevent browser caching of the image,
* but major browsers appear to handle fine.
*/
'signed' => false,
],

/**
* By default, images receive a `max-width: {originalImageWidth}` rule,
* so that CSS will not upscale them beyond their original width. This
* can be overridden on a per-image basis using the `grow` function
* parameter. However, it can also be configured globally here.
*/
'grow' => false,

/**
* The default image scales to generate.
*/
Expand All @@ -30,21 +53,6 @@
10000,
],

'route' => [
/**
* The domain that will be used to generate the Glide URLs.
*/
'domain' => null,

/**
* Whether the generated Glide URLs should be signed.
* For some browsers this differing query string
* might prevent browser caching of the image,
* but major browsers appear to handle fine.
*/
'signed' => false,
],

/**
* By default, upscaling is enabled up to 2x the original image size.
* This is due to Retina / HiDPI-displays, where it can be crisper
Expand Down
4 changes: 3 additions & 1 deletion src/GlideImageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

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

$grow = $grow ?? config('glide.grow');

$isGlideSupported = $this->isGlideSupported($path);

$attributes->setAttributes([
Expand Down
Loading