0

having this code:

$this->helper('catalog/image')->init($_product, 'slider_img')->resize(400,300)

how to check if the 'slider_img' exists?

3

was easy:

if ($_product->getSliderImg())

UPDATE:

Found a better way to avoid any image exception using try/catch:


try {
  $product_img = $this->helper('catalog/image')->init($_product, 'header_slider_img')
}
catch (Exception $e) {
  Mage::log('Image '.$e->getMessage(), null, 'image_exception.log');
}
2
  • 1
    I can't, I've to wait 2 days Dec 2 '14 at 0:22
  • if ($_product->getSliderImg() != 'no_selection') would be more proper for first solution, as image never returns false from what I know.
    – gnysek
    Mar 30 at 9:56

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.