Browse files

Keep Item_Model::scale_dimensions from upscaling. Fixes #1579.

  • Loading branch information...
1 parent b8124ef commit e2b0f92007eb9ef2fad994c9f8957df0bfcbeccf @bharat bharat committed Jan 5, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 modules/gallery/models/item.php
View
6 modules/gallery/models/item.php
@@ -653,14 +653,18 @@ public function thumb_img($extra_attrs=array(), $max=null, $center_vertically=fa
/**
* Calculate the largest width/height that fits inside the given maximum, while preserving the
- * aspect ratio.
+ * aspect ratio. Don't upscale.
* @param int $max Maximum size of the largest dimension
* @return array
*/
public function scale_dimensions($max) {
$width = $this->thumb_width;
$height = $this->thumb_height;
+ if ($width <= $max && $height <= $max) {
+ return array($height, $width);
+ }
+
if ($height) {
if (isset($max)) {
if ($width > $height) {

0 comments on commit e2b0f92

Please sign in to comment.