Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
3b41b6fc
Commit
3b41b6fc
authored
Oct 27, 2007
by
Nigel McNie
Browse files
Support in the parameter getting stuff for maxwidth/maxheight specifications for image sizes.
parent
a70ec220
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/web.php
View file @
3b41b6fc
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment