-
12-12-2019 - |
题
具有以下代码:
$this->helper('catalog/image')->init($_product, 'slider_img')->resize(400,300)
如何检查'slider_img'是否存在?
解决方案
很容易:
if ($_product->getSliderImg())
更新:
找到了一种更好的方法来避免使用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');
}
.