开发者

restricting profile images

i'm using joomla and want to restrict the user profile image size(dimension). it is default to开发者_运维百科 10Mb but i want to restrict the image dimension something like 240x320 and below can be uploaded.. thanks..


You should hack into the joomla code for that particular upload thing and use code like this for it:

list($width, $height) = getimagesize($image_file);

if ($width == 240 && $height == 320)
{
    // nice proceed
}
else
{
   // oops, invalid dimensions
}

I suspect you should place this code in controller of the plugin/component you are using the upload feature of.


I haven't used Joomla but you should see:

How to get image height and width using java?

If you are able to load the image into memory you could use Java's awt.Image class to get the width and height of the image and reject the image or scale the image to the desired size. Have a look at:

http://java.sun.com/j2se/1.5.0/docs/api/

I know that you can use JavaScript with Joomla so perhaps this would be worth a view: link text - Uses javascript to get image dimensions.

I hope this is some help to you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜