Commit a70ec220 authored by Nigel McNie's avatar Nigel McNie

Add support for max width/height specifications for images. This means that...

Add support for max width/height specifications for images. This means that images smaller than this will not be scaled up, which is better behaviour in many situations.
parent 2815f4f5
......@@ -510,6 +510,34 @@ function image_get_new_dimensions($oldx, $oldy, $size) {
log_debug("Resizing so HEIGHT = " . $size['h']);
log_debug("New dimensions: $newx x $newy");
}
else if (isset($size['maxw'])) {
// Else if just maximum width
if ($oldx > $size['maxw']) {
$newx = $size['maxw'];
$newy = ($oldy * $newx) / $oldx;
log_debug("maxwidth: Resizing so WIDTH = " . $size['maxw']);
log_debug("New dimensions: $newx x $newy");
}
else {
log_debug('maxwidth: image width smaller than maxwidth, doing nothing');
$newx = $oldx;
$newy = $oldy;
}
}
else if (isset($size['maxh'])) {
// Else if just maximum height
if ($oldy > $size['maxh']) {
$newy = $size['maxh'];
$newx = ($oldx * $newy) / $oldy;
log_debug("Resizing so HEIGHT = " . $size['maxh']);
log_debug("New dimensions: $newx x $newy");
}
else {
log_debug('maxheight: image height smaller than maxheight, doing nothing');
$newx = $oldx;
$newy = $oldy;
}
}
else {
log_debug("Unknown size specification:");
log_debug($size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment