mirror of
https://github.com/processwire/processwire.git
synced 2025-08-12 09:44:38 +02:00
Attempt fix for processwire/processwire-issues#1351
This commit is contained in:
@@ -842,22 +842,31 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
|||||||
if(strpos($cropping, ',')) {
|
if(strpos($cropping, ',')) {
|
||||||
$cropping = explode(',', $cropping);
|
$cropping = explode(',', $cropping);
|
||||||
} else if(strpos($cropping, 'x') && preg_match('/^([pd])(\d+)x(\d+)(z\d+)?/', $cropping, $matches)) {
|
} else if(strpos($cropping, 'x') && preg_match('/^([pd])(\d+)x(\d+)(z\d+)?/', $cropping, $matches)) {
|
||||||
$cropping = array(0 => $matches[1], 1 => $matches[2]);
|
$cropping = array(
|
||||||
if(isset($matches[3])) $cropping[2] = (int) $matches[3];
|
0 => (int) $matches[2], // x
|
||||||
if($matches[1] == 'p') {
|
1 => (int) $matches[3] // y
|
||||||
$cropping[0] .= '%';
|
);
|
||||||
|
if(isset($matches[4])) {
|
||||||
|
$cropping[2] = (int) ltrim($matches[4], 'z'); // zoom
|
||||||
|
}
|
||||||
|
if($matches[1] == 'p') { // percent
|
||||||
$cropping[0] .= '%';
|
$cropping[0] .= '%';
|
||||||
|
$cropping[1] .= '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(is_array($cropping)) {
|
if(is_array($cropping)) {
|
||||||
if(strpos($cropping[0], '%') !== false) {
|
if(strpos($cropping[0], '%') !== false) {
|
||||||
$cropping[0] = round(min(100, max(0, $cropping[0]))) . '%';
|
$v = trim($cropping[0], '%');
|
||||||
|
if(ctype_digit(trim($v, '-'))) $v = (int) $v;
|
||||||
|
$cropping[0] = round(min(100, max(0, $v))) . '%';
|
||||||
} else {
|
} else {
|
||||||
$cropping[0] = (int) $cropping[0];
|
$cropping[0] = (int) $cropping[0];
|
||||||
}
|
}
|
||||||
if(strpos($cropping[1], '%') !== false) {
|
if(strpos($cropping[1], '%') !== false) {
|
||||||
$cropping[1] = round(min(100, max(0, $cropping[1]))) . '%';
|
$v = trim($cropping[1], '%');
|
||||||
|
if(ctype_digit(trim($v, '-'))) $v = (int) $v;
|
||||||
|
$cropping[1] = round(min(100, max(0, $v))) . '%';
|
||||||
} else {
|
} else {
|
||||||
$cropping[1] = (int) $cropping[1];
|
$cropping[1] = (int) $cropping[1];
|
||||||
}
|
}
|
||||||
@@ -867,12 +876,19 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cropping === true) $cropping = true; // default, crop to center
|
if($cropping === true) {
|
||||||
else if(!$cropping) $cropping = false;
|
$cropping = true; // default, crop to center
|
||||||
else if(is_array($cropping)) {} // already took care of it above
|
} else if(!$cropping) {
|
||||||
else if(in_array($cropping, self::$croppingValues)) $cropping = array_search($cropping, self::$croppingValues);
|
$cropping = false;
|
||||||
else if(array_key_exists($cropping, self::$croppingValues)) {}
|
} else if(is_array($cropping)) {
|
||||||
else $cropping = true; // unknown value or 'center', default to TRUE/center
|
// already took care of it above
|
||||||
|
} else if(in_array($cropping, self::$croppingValues)) {
|
||||||
|
$cropping = array_search($cropping, self::$croppingValues);
|
||||||
|
} else if(array_key_exists($cropping, self::$croppingValues)) {
|
||||||
|
// okay
|
||||||
|
} else {
|
||||||
|
$cropping = true; // unknown value or 'center', default to TRUE/center
|
||||||
|
}
|
||||||
|
|
||||||
return $cropping;
|
return $cropping;
|
||||||
}
|
}
|
||||||
@@ -897,7 +913,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
|||||||
$zoom = isset($cropping[2]) ? (int) $cropping[2] : 0;
|
$zoom = isset($cropping[2]) ? (int) $cropping[2] : 0;
|
||||||
$cropping =
|
$cropping =
|
||||||
(strpos($cropping[0], '%') !== false ? 'p' : 'd') .
|
(strpos($cropping[0], '%') !== false ? 'p' : 'd') .
|
||||||
((int) $cropping[0]) . 'x' . ((int) $cropping[1]);
|
((int) rtrim($cropping[0], '%')) . 'x' . ((int) rtrim($cropping[1], '%'));
|
||||||
if($zoom > 1 && $zoom < 100) $cropping .= "z$zoom";
|
if($zoom > 1 && $zoom < 100) $cropping .= "z$zoom";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user