Get Product Custom (Gallery) Image Attribute with Label

On Product List page write below code with necessary modifications : 

<?php $product=Mage::getModel('catalog/product')->load($_product->getId()); ?>
<?php if($product->getData('upsell_media_sticker')) :?>
    <div class="sticker" style="position: absolute; top: 100px;">
        <img src="<?php echo $this->helper('catalog/image')->init($product, 'upsell_media_sticker')->resize(125,60); ?>" />

        <?php $customimg = $product->getMediaGalleryImages()->getItemByColumnValue('file',$product->getData('upsell_media_sticker')); ?>
        <?php if($customimg->getLabel()): ?>
        <label style="font-weight:bold; color: red; top:22px; left:10px; position: absolute;">
            <?php echo $customimg->getLabel(); ?>
        </label>
        <?php endif; ?>
    </div>
<?php endif; ?>

No comments:

Post a Comment