Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Update libraries/joomla/image/image.php
Browse files Browse the repository at this point in the history
  • Loading branch information
romacron committed Apr 3, 2012
1 parent 07b9fea commit 3c28b42
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions libraries/joomla/image/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,37 @@ protected function prepareDimensions($width, $height, $scaleMethod)

case JImage::SCALE_INSIDE:
case JImage::SCALE_OUTSIDE:
$rx = $this->getWidth() / $width;
$ry = $this->getHeight() / $height;
if ($width == 0 && $height != 0)
{
// To avoid dividing by $width if it is zero
$rx = 0;
$ry = $this->getHeight() / $height;

if ($scaleMethod == JImage::SCALE_INSIDE)
}
elseif ($width != 0 && $height == 0)
{
// To avoid dividing by $height if it is zero
$rx = $this->getWidth() / $width;
$ry = 0;

}
elseif ($width == 0 && $height == 0)
{
// Both $height and $width are zero
$rx = $this->getWidth() / $width;
$ry = 0;

}
else
{ // If both $width and $height are not equals to zero
$rx = $this->getWidth() / $width;
$ry = $this->getHeight() / $height;

}
if ($scaleMethod == self::SCALE_INSIDE)
{
$ratio = ($rx > $ry) ? $rx : $ry;

}
else
{
Expand Down

0 comments on commit 3c28b42

Please sign in to comment.