Commit 3b41b6fc authored by Nigel McNie's avatar Nigel McNie
Browse files

Support in the parameter getting stuff for maxwidth/maxheight specifications for image sizes.

parent a70ec220
......@@ -902,11 +902,15 @@ function param_imagesize($name) {
* The result of this function can be passed to get_dataroot_image_path to
* retrieve the filesystem path of the appropriate image
*/
function get_imagesize_parameters($sizeparam='size', $widthparam='width', $heightparam='height', $maxsizeparam='maxsize') {
$size = param_imagesize($sizeparam, '');
$width = param_integer($widthparam, 0);
$height = param_integer($heightparam, 0);
$maxsize = param_integer($maxsizeparam, 0);
function get_imagesize_parameters($sizeparam='size', $widthparam='width', $heightparam='height',
$maxsizeparam='maxsize', $maxwidthparam='maxwidth', $maxheightparam='maxheight') {
$size = param_imagesize($sizeparam, '');
$width = param_integer($widthparam, 0);
$height = param_integer($heightparam, 0);
$maxsize = param_integer($maxsizeparam, 0);
$maxwidth = param_integer($maxwidthparam, 0);
$maxheight = param_integer($maxheightparam, 0);
$imagemaxwidth = get_config('imagemaxwidth');
$imagemaxheight = get_config('imagemaxheight');
......@@ -941,6 +945,24 @@ function get_imagesize_parameters($sizeparam='size', $widthparam='width', $heigh
}
return array('h' => $height);
}
if ($maxwidth) {
if ($maxwidth > $imagemaxwidth) {
throw new ParameterException('Requested image size is too big');
}
if ($maxwidth < 16) {
throw new ParameterException('Requested image size is too small');
}
return array('maxw' => $maxwidth);
}
if ($maxheight) {
if ($maxheight > $imagemaxheight) {
throw new ParameterException('Requested image size is too big');
}
if ($maxheight < 16) {
throw new ParameterException('Requested image size is too small');
}
return array('maxh' => $maxheight);
}
return null;
}
......
Supports Markdown
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