Method: size::fit
Fits width and height into a defined box and keeps the ratio
Info
Syntax
size::fit($width, $height, $box, $force=false)
Parameters
- $width (int)
- $height (int)
- $box (int)
- $force (boolean) If width and height are smaller than the box this will force upscaling
Return (array)
An array with a key and value for width and height
Example
$new_size = size::fit(1200, 768, 500);
// output: array(
// 'width' => 500,
// 'height' => 320
// );
$new_size = size::fit(1200, 768, 3000, true);
// output: array(
// 'width' => 3000,
// 'height' => 1920
// );