1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 17:54:44 +02:00
This commit is contained in:
Ryan Cramer
2018-09-26 11:04:53 -04:00
parent 42ec0e3cf4
commit 42511ebb77

View File

@@ -1017,11 +1017,19 @@ class Pageimage extends Pagefile {
*/ */
public function maxSize($width, $height, $options = array()) { public function maxSize($width, $height, $options = array()) {
if($width < 1 || $this->width() <= $width) $width = 0; $adjustedWidth = $width < 1 || $this->width() <= $width ? 0 : $width;
if($height < 1 || $this->height() <= $height) $height = 0; $adjustedHeight = $height < 1 || $this->height() <= $height ? 0 : $height;
// if already within maxSize dimensions then do nothing // if already within maxSize dimensions then do nothing
if(!$width && !$height) return $this; if(!$adjustedWidth && !$adjustedHeight) {
if(empty($options)) return $this; // image already within target
$adjustedWidth = $width;
$options['nameHeight'] = $height;
} else if(!$adjustedWidth) {
$options['nameWidth'] = $width;
} else if(!$adjustedHeight) {
$options['nameHeight'] = $height;
}
$options['upscaling'] = false; $options['upscaling'] = false;
$options['cropping'] = false; $options['cropping'] = false;
@@ -1034,7 +1042,7 @@ class Pageimage extends Pagefile {
$options['suffix'] = $suffix; $options['suffix'] = $suffix;
} }
return $this->size($width, $height, $options); return $this->size($adjustedWidth, $adjustedHeight, $options);
} }
/** /**