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

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
// );