public static get ( string $image, integer $width, integer $height, string $mode = '', string $target = null, boolean $force = false ) : string | null | ||
$image | string | The image path |
$width | integer | The target width |
$height | integer | The target height |
$mode | string | The resize mode |
$target | string | An optional target path |
$force | boolean | Override existing target images |
return | string | null | The path of the resized image or null |
public static function get($image, $width, $height, $mode = '', $target = null, $force = false)
{
@trigger_error('Using Image::get() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_factory service instead.', E_USER_DEPRECATED);
if ($image == '') {
return null;
}
try {
$imageObj = static::create($image, array($width, $height, $mode));
$imageObj->setTargetPath($target);
$imageObj->setForceOverride($force);
if (($path = $imageObj->executeResize()->getResizedPath()) != '') {
return $path;
}
} catch (\Exception $e) {
\System::log('Image "' . $image . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);
}
return null;
}
public function generateLabel($row, $label) { $sReturn = ''; $objFile = \FilesModel::findByPk(deserialize($row['logo'])); if ($objFile->path != '') { $sReturn = '<figure style="float: left; margin-right: 1em;"><img src="' . Image::get($objFile->path, 80, 50, 'center_center') . '"></figure>'; } $sReturn .= '<div>' . $label . '</div>'; return $sReturn; }