Reputation: 700
I am trying to include a custom image attribute in list.phtml. The attribute is included in the product collection using the addAttribute method in catalog.xml:
<action method="addAttribute"><code>hover_image</code></action>
If I try $_product->getHoverImage, I get the url fine. But when I try to resize the image using:
$this->helper('catalog/image')->init($_product, 'hover_image')->resize(240,186)
It doesn't work, I receive a error "Image file was not found."
Upvotes: 1
Views: 2786
Reputation: 700
I managed to get it to work with a simple if statement:
<?php if($_product->getHoverImage()): ?>
<?php echo $this->helper('catalog/image')->init($_product,'hover_image')->resize(240,186); ?>
<?php endif; ?>
Upvotes: 3