/**
* @param array{width: int, height: int} $imageSize
*
* @return array{width: int, height: int}
*/
private function calculateThumbnailSize( array
$imageSize,
MediaThumbnailSizeEntity
$preferredThumbnailSize,
MediaFolderConfigurationEntity
$config ): array
{ if (!
$config->
getKeepAspectRatio() ||
$preferredThumbnailSize->
getWidth() !==
$preferredThumbnailSize->
getHeight()) { $calculatedWidth =
$preferredThumbnailSize->
getWidth();
$calculatedHeight =
$preferredThumbnailSize->
getHeight();
$useOriginalSizeInThumbnails =
$imageSize['width'
] <
$calculatedWidth ||
$imageSize['height'
] <
$calculatedHeight;
return $useOriginalSizeInThumbnails ?
[ 'width' =>
$imageSize['width'
],
'height' =>
$imageSize['height'
],
] :
[ 'width' =>
$calculatedWidth,
'height' =>
$calculatedHeight,
];