Sign up to our newsletter to receive updates on Winter CMS releases,
new features in the works, and much more.
We'll never spam or give
this address away.
The Image Resizing service can be used for resizing any image resources accessible to the application.
It works by accepting a variety of image sources and normalizing the pipeline for storing the desired resizing configuration and then deferring the actual resizing of the images until requested by the browser. When the resizer route is hit, the configuration is retrieved from the cache and used to generate the desired image and then redirect to the generated images static path to minimize the load on the server.
Future loads of the image are automatically pointed to the static URL of the resized image without even hitting the resizer route.
The functionality of this class is controlled by these config items:
NOTE: The image resizing service requires a cache driver that persists cache data between requests in order to function,
array
is not a supported cache driver if you wish to use this service.
The Image Resizer can be access through a number of different methods:
image
backend list columnsgetThumb()
on Winter\Storm\Database\Attach\File
models| resize
filter$image
source to System\Classes\ImageResizer::filterGetUrl()
System\Classes\ImageResizer
class and using that as desiredThe basic parameters provided to the ImageResizer are (int) $width
, (int) $height
, and (array) $options
.
If $width
or $height
is falsey or 'auto'
, that value is calculated using original image ratio (automatic proportional scaling).
The following elements are supported in the options array are supported:
Key | Description | Default | Options |
---|---|---|---|
mode |
How the image should be fitted to dimensions | auto |
exact , portrait , landscape , auto , fit , or crop |
offset |
Offset the crop of the resized image | [0,0] |
[left, top] |
quality |
Quality of the resized image | 90 |
0-100 |
sharpen |
Amount to sharpen the image | 0 |
0-100 |
The mode
option allows you to specify how the image should be resized. The available modes are as follows:
Mode | Description |
---|---|
auto |
Automatically choose between portrait and landscape based on the image's orientation |
exact |
Resize to the exact dimensions given, without preserving aspect ratio |
portrait |
Resize to the given height and adapt the width to preserve aspect ratio |
landscape |
Resize to the given width and adapt the height to preserve aspect ratio |
crop |
Crop to the given dimensions after fitting as much of the image as possible inside those |
fit |
Fit the image inside the given maximal dimensions, keeping the aspect ratio |
The available sources that images can be resized from are as follows:
\Winter\Storm\Database\Attach\File
modelAvailable sources can be extended by listening to the system.resizer.getAvailableSources
event
Sign up to our newsletter to receive updates on Winter CMS releases,
new features in the works, and much more.
We'll never spam or give
this address away.
Released October 20, 2022
14 UX/UI Improvements, 25 API Changes, 33 Bug Fixes, 4 Security Improvements, 5 Translation Improvements, 1 Performance Improvement, 2 Community Improvements, 2 Dependencies, 0 New Contributors
* @cstorus made their first contribution in https://github.com/wintercms/winter/pull/616
* @simonmannsfeld made their first contribution in https://github.com/wintercms/winter/pull/623
* @quangtrongonline made their first contribution in https://github.com/wintercms/winter/pull/636
* @nathanlesage made their first contribution in https://github.com/wintercms/winter/pull/665
* @vllvll made their first contribution in https://github.com/wintercms/winter/pull/669
* @robertalexa made their first contribution in https://github.com/wintercms/winter/pull/668
* @iamyigitkoc made their first contribution in https://github.com/wintercms/winter/pull/624
* @hecc127 made their first contribution in https://github.com/wintercms/winter/pull/682
* @prsuhas made their first contribution in https://github.com/wintercms/winter/pull/723