GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/ve.anqa.it/wp-content/plugins/depicter/vendor/averta/core/src/Utility/Media.php
<?php

namespace Averta\Core\Utility;

class Media{

    /**
	 * Calculates new width and height to fit the media in a box size
	 *
	 * @param string $type     Resize type. "cover" or "contain"
	 * @param int $boxWidth    Width of the box to fit the media in
	 * @param int $boxHeight   Height of the box to fit the media in
	 * @param int $width       Original width of the media
	 * @param int $height      Original height of the media
	 *
	 * @return float[]|int[]
	 */
	public static function fitInBox( $type, $boxWidth, $boxHeight, $width, $height ) {
		$widthRatio  = $width  ? $boxWidth  / $width  : 1;
		$heightRatio = $height ? $boxHeight / $height : 1;

		$ratio = $type === 'cover' ? max( $widthRatio, $heightRatio ) : min( $widthRatio, $heightRatio );

		return [
			$width  * $ratio,
			$height * $ratio,
		];
	}
}