Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

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

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
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

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