mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 17:54:44 +02:00
Fix issue processwire/processwire-issues#454 for Pageimage::maxSize()
This commit is contained in:
@@ -400,16 +400,6 @@ class Pageimage extends Pagefile {
|
|||||||
*/
|
*/
|
||||||
protected function ___size($width, $height, $options) {
|
protected function ___size($width, $height, $options) {
|
||||||
|
|
||||||
// I was getting unnecessarily resized images without this code below,
|
|
||||||
// but this may be better solved in ImageSizer?
|
|
||||||
/*
|
|
||||||
$w = $this->width();
|
|
||||||
$h = $this->height();
|
|
||||||
if($w == $width && $h == $height) return $this;
|
|
||||||
if(!$height && $w == $width) return $this;
|
|
||||||
if(!$width && $h == $height) return $this;
|
|
||||||
*/
|
|
||||||
|
|
||||||
if($this->ext == 'svg') return $this;
|
if($this->ext == 'svg') return $this;
|
||||||
|
|
||||||
if(!is_array($options)) {
|
if(!is_array($options)) {
|
||||||
@@ -832,13 +822,18 @@ class Pageimage extends Pagefile {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function maxSize($width, $height, $options = array()) {
|
public function maxSize($width, $height, $options = array()) {
|
||||||
$w = $this->width();
|
$options['upscaling'] = false;
|
||||||
$h = $this->height();
|
$options['cropping'] = false;
|
||||||
if($w >= $h) {
|
|
||||||
return $this->maxWidth($width, $options);
|
if($this->wire('config')->installed > 1513336849) {
|
||||||
} else {
|
// New installations from 2017-12-15 forward use an "ms" suffix for images from maxSize() method
|
||||||
return $this->maxHeight($height, $options);
|
$suffix = isset($options['suffix']) ? $options['suffix'] : array();
|
||||||
|
if(!is_array($suffix)) $suffix = array();
|
||||||
|
$suffix[] = 'ms';
|
||||||
|
$options['suffix'] = $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->size($width, $height, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user