Monday 18 August 2014

How to get product base image in magento

<?php $_gallery = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages();  ?>
           <?php if (count($_gallery) > 0): ?>
          
                    <?php foreach ($_gallery as $_image ):  ?>
                    <?php if($this->htmlEscape($_image->getLabel())=="hover"):
                   
              ?>
                            <a href="<?php echo $_product->getProductUrl() ?>"   title="<?php echo $this->htmlEscape($_product->getName()) ?>" onmouseout="imgout(this);" style="display:none;" id="hover_<?php echo $i;?>">    <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize(135, 135); ?>" width="135" height="135"  alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"   /></a>
                      <?php endif; ?>
                     
                     <?php endforeach;  ?>
                  
                <?php endif; ?>   
</div>

No comments:

Post a Comment