0

I am using this code to store particular product image size in my own different folder. but it is storing all the size images in "p1" folder.my image width is 500 and height could be any should be store in p1/c/ . another is width with 280 and height any should be save in p2/c/.

any solution for this?

 if(($this->_width == 500) || (!empty($this->_height))) 
    {

    $path = array(
          //  Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
         Mage::getSingleton('catalog/product_media_config'),
           // 'cache',
          //  Mage::app()->getStore()->getId(),
            $path[] = 'p1/C:' // $this->getDestinationSubdir()
        );

}  
elseif(($this->_width == 280) || (!empty($this->_height)))
{

       $path = array(
          //  Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
         Mage::getSingleton('catalog/product_media_config'),
           // 'cache',
          //  Mage::app()->getStore()->getId(),
            $path[] = 'p2/C:' // $this->getDestinationSubdir()
        ); 
}

else
{

   $path = array(
          //  Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
         Mage::getSingleton('catalog/product_media_config'),
           // 'cache',
          //  Mage::app()->getStore()->getId(),
            $path[] = 'R/C:' // $this->getDestinationSubdir()
        ); 

} 
1
  • Programming style: beware that this usage of curly braces can be problematic with JavaScript encosia.com/… Aug 7, 2015 at 14:44

1 Answer 1

0

I think your conditionals are wrong, you don't need the !empty($this->_height) part if you don't care about height, if I have understood what you want

So, it should be...

if ($this->_width == 500) {
    ...
} elseif ($this->_width == 280) {
    ...
} else {
    ...
}
2
  • its not working for me..any other solution
    – Donika
    Aug 8, 2015 at 4:21
  • In that case, please edit your post & clean your code to make it readable. Error should be there Aug 8, 2015 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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