I want To validate Image Height And Width on Submit in Magento Admin Back-end. I want to upload & different Sizes Of Images by magento admin...So For That I want to validate image Height and Width In magento admin form upload field...

$fieldset->addField('image_1', 'file', array(
            'label' => Mage::helper('frontlayout')->__('Layout Image'),
            'required' => true,
            'name' => 'image_1',
            'class' => 'required-entry',

If you are looking to validate the image uploaded for the catalog<

public function validateUploadFile($filePath) {

    $testsize[] = getimagesize($filePath);
    if (!(getimagesize($filePath)) || ($testsize[0][0] < 900) || ($testsize[0][1] < 900)) {
        Mage::throwException($this->__('Image size must be same or greater than 900px * 900px .'));

    $_processor = new Varien_Image($filePath);
    return $_processor->getMimeType() !== null;
  • solution needed in prototype not in php
    – Deepak Rai
    Dec 22 '15 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.