if ($size > 0) {
$image->thumbnailFixedShorterSide($size);
if ($image->getOrientation() != XenForo_Image_Abstract::ORIENTATION_SQUARE) {
$x = floor(($image->getWidth() - $size) / 2);
$y = floor(($image->getHeight() - $size) / 2);
$image->crop($x, $y, $size, $size);