Skip to content

Commit

Permalink
Use important part also if no image size record is used
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Oct 2, 2014
1 parent abf98b8 commit d719730
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions system/modules/core/library/Contao/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -1288,20 +1288,20 @@ public static function get($image, $width, $height, $mode='', $target=null, $for
->setTargetPath($target)
->setForceOverride($force);

$fileRecord = \FilesModel::findByPath($image);
if ($fileRecord && $fileRecord->importantPartWidth && $fileRecord->importantPartHeight)
{
$imageObj->setImportantPart(array(
'x' => (int)$fileRecord->importantPartX,
'y' => (int)$fileRecord->importantPartY,
'width' => (int)$fileRecord->importantPartWidth,
'height' => (int)$fileRecord->importantPartHeight,
));
}

// Load the image size from the database if $mode is an id
if (is_numeric($mode) && $imageSize = \ImageSizeModel::findByPk($mode))
{
$fileRecord = \FilesModel::findByPath($image);
if ($fileRecord && $fileRecord->importantPartWidth && $fileRecord->importantPartHeight)
{
$imageObj->setImportantPart(array(
'x' => (int)$fileRecord->importantPartX,
'y' => (int)$fileRecord->importantPartY,
'width' => (int)$fileRecord->importantPartWidth,
'height' => (int)$fileRecord->importantPartHeight,
));
}

$imageObj->setTargetWidth($imageSize->width)
->setTargetHeight($imageSize->height)
->setResizeMode($imageSize->resizeMode)
Expand Down

0 comments on commit d719730

Please sign in to comment.