public function showImage($fileName = null, $width = null, $height = null, $crop = null)
{
if (empty($fileName)) {
return '';
}
$thumb = $this->getThumbnail($fileName, $width, $height, $crop);
if ($width === null && $height === null) {
$thumbconf = $this->app['config']->get('general/thumbnails');
$width = !empty($thumbconf['default_image'][0]) ? $thumbconf['default_image'][0] : 1000;
$height = !empty($thumbconf['default_image'][1]) ? $thumbconf['default_image'][1] : 750;
$thumb->setWidth($width);
$thumb->setHeight($height);
} elseif ($width === null xor $height === null) {
$info = $this->imageInfo($thumb->getFileName(), false)->getInfo();
if ($width !== null) {
$width = min($width, $info->getWidth());
$thumb->setHeight(round($width / $info->getAspectRatio()));
} elseif ($height !== null) {
$height = min($height, $info->getHeight());
$thumb->setWidth(round($height * $info->getAspectRatio()));
} else {
$thumb->setWidth($info->getWidth());
$thumb->setHeight($info->getHeight());
}
}
return sprintf('<img src="%s" width="%s" height="%s" alt="%s">', $this->getThumbnailUri($thumb), $thumb->getWidth(), $thumb->getHeight(), $thumb->getAltTitle());
}