Skip to content

Commit 26fce3e

Browse files
committed
docs: add image caching and version option
1 parent 92de082 commit 26fce3e

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,42 @@ http://localhost:8000/image-transform/width=250,quality=80,format=webp/foo/bar/e
6161
> [!NOTE]
6262
> The options are separated by commas and their values are appended with equal signs. The order of options does not matter.
6363
64-
| Option | Description | Type | Possible Values |
65-
| ---------- | ------------------------------------ | ------ | ------------------------------------------------------------- |
66-
| `width` | Set the width of the image. | number | Values greater than the original width will be ignored. |
67-
| `height` | Set the height of the image. | number | Values greater than the original height will be ignored. |
68-
| `quality` | Set the quality of the image. | number | `0` to `100` |
69-
| `format` | Set the format of the image. | string | Supported formats: `jpg`, `jpeg`, `png`, `gif`, `webp`. |
70-
| `blur` | Set the blur level of the image. | number | `0` to `100` |
71-
| `contrast` | Set the contrast level of the image. | number | `-100` to `100` |
72-
| `flip` | Flip the image. | string | `h`(horizontal), `v`(vertical), `hv`(horizontal and vertical) |
64+
| Option | Description | Type | Description / Possible Values |
65+
| ---------- | ------------------------------------ | ------- | ------------------------------------------------------------------------------- |
66+
| `width` | Set the width of the image. | integer | Values greater than the original width will be ignored. |
67+
| `height` | Set the height of the image. | integer | Values greater than the original height will be ignored. |
68+
| `quality` | Set the quality of the image. | integer | `0` to `100` |
69+
| `format` | Set the format of the image. | string | Supported formats: `jpg`, `jpeg`, `png`, `gif`, `webp`. |
70+
| `blur` | Set the blur level of the image. | integer | `0` to `100` |
71+
| `contrast` | Set the contrast level of the image. | integer | `-100` to `100` |
72+
| `flip` | Flip the image. | string | `h`(horizontal), `v`(vertical), `hv`(horizontal and vertical) |
73+
| `version` | Version number of the image. | integer | Any positive integer. More info in the [Image Caching](#image-caching) section. |
7374

7475
> [!CAUTION]
7576
> The `blur` option is a resource-intensive operation and may cause memory issues if the image is too large. It is recommended to use this option with caution, or disable it in the config.
7677
78+
## Image Caching
79+
80+
This package comes with the default option to automatically store and serve images statically for the requested options within the caching lifetime.
81+
82+
> [!NOTE]
83+
> Having this feature enabled (default behavior) will help to reduce the load on your server and speed up image delivery.
84+
85+
The processed images are stored in the `storage/app/private/_cache/image-transform-url` directory by default. You can change the disk configuration in the `image-transform-url.php` configuration file.
86+
87+
> [!CAUTION]
88+
> When using this option, there is one caveat to be aware of:
89+
90+
Source images are considered to be stale content by their file name and path.
91+
92+
If the content of an original source image changes, but the file name stays the same, the cached images will not be updated automatically until the cache expires.
93+
To force a revalidation, you can either:
94+
95+
1. change the image's file name
96+
2. move it into another subdirectory, which will change its path
97+
3. change the version number (integer) in the options (e.g. `version=2`)
98+
4. or flush the entire cache of your application using the `php artisan cache:clear` command.
99+
77100
## Testing
78101

79102
```bash

0 commit comments

Comments
 (0)