Custom image aspect
Permalink
Is it possible to specify an image aspect ratio/size when requiring an image for a block or a page type? The flow I would like to see is: "Select Image" > open file browser > select image > open image editor in crop mode > move/zoom image > save a cropped version for the page/block. Ideally the original image would not be maintained in it's original state.
You can specify an image aspect ratio or crop to a specific size using the image helper and getThumbnail(). The user only has to select an image, the resizing/cropping is done automatically.
Example: resize
- the first argument for getThumbnail() is the image object
- the second argument for getThumbnail() is the max width in pixels
- the third argument for getThumbnail() is the max height in pixels
- the fourth argument for getThumbnail() is boolean for cropping
In this example the image will have a maximum width of 1000px and a height that maintains the aspect ratio.
Example: crop
In this example the image will be cropped to a maximum 300 x 300 pixels.