Skip to content

Kirby 5.0.0

$dimensions->fit()

Recalculates the width and height to fit into the given box.

$dimensions->fit(int $box, bool $force = false): Kirby\Image\Dimensions

Parameters

Name Type Default Description
$boxrequired int no default value the max width and/or height
$force bool false If true, the dimensions will be
upscaled to fit the box if smaller

Return type

Kirby\Image\Dimensions

object with recalculated dimensions

This method modifies the existing $ object it is applied to and returns it again.

Parent class

Kirby\Image\Dimensions

Examples

$dimensions = new Dimensions(1200, 768);
$dimensions->fit(500);