src/Service.php
private function _getImageToSize(array $images, int $size)
	{
		$selectedImage = null;
		$selectedSize = 0;

		foreach ($images as $image)
		{
			if (is_array($image))
			{
				$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
				$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
				$imageSize = max($imageWidth, $imageHeight);

				if (!$selectedImage ||
					($selectedSize < $size && $imageSize > $selectedSize) ||
					($selectedSize > $imageSize && $imageSize > $size))
				{
					$selectedImage = $image;
					$selectedSize = $imageSize;
				}
			}
		}

		return $selectedImage;
	}
private function _getImageToSize(array $images, int $size)
	{
		$selectedImage = null;
		$selectedSize = 0;

		foreach ($images as $image)
		{
			if (is_array($image))
			{
				$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
				$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
				$imageSize = max($imageWidth, $imageHeight);

				if (!$selectedImage ||
					($selectedSize < $size && $imageSize > $selectedSize) ||
					($selectedSize > $imageSize && $imageSize > $size))
				{
					$selectedImage = $image;
					$selectedSize = $imageSize;
				}
			}
		}

		return $selectedImage;
	}
private function _getImageToSize ( array $ images , int $ size ) { $ selectedImage = null ; $ selectedSize = 0 ; foreach ( $ images as $ image ) { if ( is_array ( $ image ) ) { $ imageWidth = isset ( $ image [ 'width' ] ) && is_numeric ( $ image [ 'width' ] ) ? $ image [ 'width' ] : 0 ; $ imageHeight = isset ( $ image [ 'height' ] ) && is_numeric ( $ image [ 'height' ] ) ? $ image [ 'height' ] : 0 ; $ imageSize = max ( $ imageWidth , $ imageHeight ) ; if ( ! $ selectedImage || ( $ selectedSize < $ size && $ imageSize > $ selectedSize ) || ( $ selectedSize > $ imageSize && $ imageSize > $ size ) ) { $ selectedImage = $ image ; $ selectedSize = $ imageSize ; } } } return $ selectedImage ; }
Helper method for retrieving an image closest to some size.

@param array $images
@param int $size
@return array|null
Helper method for retrieving an image closest to some size .