Skip to content

Commit

Permalink
Deal in integers when doing aspect ratio operations. Fixes #1470.
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Oct 31, 2010
1 parent dff1a53 commit f01fad1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/gallery/models/item.php
Expand Up @@ -628,7 +628,7 @@ public function thumb_img($extra_attrs=array(), $max=null, $center_vertically=fa
list ($height, $width) = $this->scale_dimensions($max);
if ($center_vertically && $max) {
// The constant is divide by 2 to calculate the file and 10 to convert to em
$margin_top = ($max - $height) / 20;
$margin_top = (int)(($max - $height) / 20);
$extra_attrs["style"] = "margin-top: {$margin_top}em";
$extra_attrs["title"] = $this->title;
}
Expand Down Expand Up @@ -656,10 +656,10 @@ public function scale_dimensions($max) {
if ($height) {
if (isset($max)) {
if ($width > $height) {
$height = (int)($max * ($height / $width));
$height = (int)($max * $height / $width);
$width = $max;
} else {
$width = (int)($max * ($width / $height));
$width = (int)($max * $width / $height);
$height = $max;
}
}
Expand Down Expand Up @@ -700,10 +700,10 @@ public function movie_img($extra_attrs) {
$height = $this->height;
if ($width > $max_size || $height > $max_size) {
if ($width > $height) {
$height *= $max_size / $width;
$height = (int)($height * $max_size / $width);
$width = $max_size;
} else {
$width *= $max_size / $height;
$width = (int)($width * $max_size / $height);
$height = $max_size;
}
}
Expand Down

0 comments on commit f01fad1

Please sign in to comment.