Question

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..

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top