Question

having this code:

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

how to check if the 'slider_img' exists?

Was it helpful?

Solution

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');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top