Try the Demo

Magento Forum

   
custom picture atrribute display
 
schmelzgeist
Sr. Member
 
Total Posts:  92
Joined:  2008-05-27
Marzipane World Capital (Lübeck, Germany)
 

a small question:

i created a custom picture atribute to display the logo of the manufacturer, i can even display it in the frontend.
trouble is: if it is empty, the rendering of the page will stop. 
that is the code for the display:

<img id="image-3" src="<?php echo $this->helper('catalog/image')->init($_product, 'manufacturer_pic')->resize(50); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />

how do i get an default picture instead of an error?  help appreciated smile

 Signature 

WE have no future because our Present is too volatile.We have only riskmanagement.
The spinning of the given moment´s scenario. *Pattern Recognition.W.Gibson*

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale
Guru
 
Avatar
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

you could do smth like this:

<?php if($_product->getManufacturerPic()) : ?>
<img id="image-3" src="<?php echo $this->helper('catalog/image')->init($_product, 'manufacturer_pic')->resize(50); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> 
<?php else: ?>
<img id="image-3" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(50); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /> 
<?php> endif; ?>

Cheers

Stefan

 Signature 

mzentrale | eCommerce - eBusiness
Agentur für eCommerce Beratung, Entwicklung & Marketing.
Magento™ Silver Partner
----

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top