aspectFit.php
Table of Contents
Functions
- aspectFit() : array{width: int, height: int}
- Scales a dimension pair to a target width or height while preserving the original aspect ratio (the locked-ratio behaviour of an aspect-ratio box).
Functions
aspectFit()
Scales a dimension pair to a target width or height while preserving the original aspect ratio (the locked-ratio behaviour of an aspect-ratio box).
aspectFit(int $width, int $height[, int|null $targetWidth = null ][, int|null $targetHeight = null ]) : array{width: int, height: int}
Provide $targetWidth to derive the matching height, or $targetHeight to
derive the matching width. If both are given, $targetWidth takes precedence
and $targetHeight is ignored. If both are null, the original pair is
returned. A non-positive original $width/$height yields an undefined
ratio: the provided targets (or the originals) are returned unchanged.
Parameters
- $width : int
-
The original (reference) width.
- $height : int
-
The original (reference) height.
- $targetWidth : int|null = null
-
The desired width, or null.
- $targetHeight : int|null = null
-
The desired height, or null.
Tags
Return values
array{width: int, height: int} —The scaled dimensions preserving the ratio.