I'm trying to add an image link to the head of my pages. This code below works except if the image isn't there, I've tried a lot of different ways but no luck. The part <?php echo $this->getImage(); ?>
works fine on it's on but it doesn't get the correct image, so I'm using it to fall back on if the other image isn't there. But I keep getting errors and the page goes blank if the image isn't there. Here's my latest attempt.
<?php if (($this->helper('catalog/image')->init(Mage::registry('current_product'), 'twitter_image')) != null): ?>
<?php $twitter_image = $this->helper('catalog/image')->init(Mage::registry('current_product'), 'twitter_image'); ?>
<?php if ($twitter_image): ?><?php echo $twitter_image; ?>
<?php else: ?>
<?php echo $this->getImage(); ?>
<?php endif; ?>
<?php endif; ?>
Any suggestions?
Thanks