From 77450f4001bc641f7a724ae5e5c2f71b44c022d1 Mon Sep 17 00:00:00 2001 From: lisps Date: Wed, 27 Nov 2013 09:38:06 +0100 Subject: media image can be resized by height (without width) --- inc/media.php | 1 + lib/exe/fetch.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/media.php b/inc/media.php index d69426414..390cd3488 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1800,6 +1800,7 @@ function media_resize_image($file, $ext, $w, $h=0){ if($info == false) return $file; // that's no image - it's a spaceship! if(!$h) $h = round(($w * $info[1]) / $info[0]); + if(!$w) $w = round(($h * $info[0]) / $info[1]); // we wont scale up to infinity if($w > 2000 || $h > 2000) return $file; diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 5967494bf..f33b3f2f8 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -78,8 +78,8 @@ if (defined('SIMPLE_TEST')) { unset($evt); //handle image resizing/cropping - if((substr($MIME, 0, 5) == 'image') && $WIDTH) { - if($HEIGHT) { + if((substr($MIME, 0, 5) == 'image') && ($WIDTH || $HEIGHT)) { + if($HEIGHT && $WDITH) { $data['file'] = $FILE = media_crop_image($data['file'], $EXT, $WIDTH, $HEIGHT); } else { $data['file'] = $FILE = media_resize_image($data['file'], $EXT, $WIDTH, $HEIGHT); -- cgit v1.2.3 From e175e163722d806ebf45aa1e9a7843c2391a5b20 Mon Sep 17 00:00:00 2001 From: lisps Date: Wed, 27 Nov 2013 09:42:41 +0100 Subject: fix indent --- inc/media.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/media.php b/inc/media.php index 390cd3488..12db36841 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1800,7 +1800,7 @@ function media_resize_image($file, $ext, $w, $h=0){ if($info == false) return $file; // that's no image - it's a spaceship! if(!$h) $h = round(($w * $info[1]) / $info[0]); - if(!$w) $w = round(($h * $info[0]) / $info[1]); + if(!$w) $w = round(($h * $info[0]) / $info[1]); // we wont scale up to infinity if($w > 2000 || $h > 2000) return $file; -- cgit v1.2.3