Like we view Gallery images in View template by default,

I tried to copy chidHtml code of View/Media for Gallery images into my List page.

But it is not working.

The code I pasted for Gallery images in my List template is,

<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <h2><?php echo $this->__('More Views') ?></h2>
    <ul class="product-image-thumbs">
    <?php $i=0; foreach ($this->getGalleryImages() as $_image): ?>
        <?php if ($this->isGalleryImageVisible($_image)): ?>
            <a class="thumb-link" href="#" title="<?php echo $this->escapeHtml($_image->getLabel()) ?>" data-image-index="<?php echo $i; ?>">
                <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(75); ?>"
                     width="75" height="75" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" />
        <?php endif; ?>
    <?php $i++; endforeach; ?>
<?php endif; ?>
  • 1
    You can not use direct above code in list file. – Suresh Chikani Oct 28 '16 at 11:15
  • 1
    view/media.phtml file is associated with Mage_Catalog_Block_Product_View_Media Block where getGalleryImages() function resides. Where as list.phtml is associated with Mage_Catalog_Block_Product_List Block. – Gopal Patel Oct 28 '16 at 11:20

if you want to call media block in list page, or any other page then you can call media block via below code

|improve this answer|||||

Please use below code :

<?php $probj=Mage::getModel('catalog/product')->load($_product->getId()); ?>
<?php $gallery_image = $probj->getMediaGalleryImages(); ?>

<?php foreach ($gallery_image as $image_gallery) :?>

<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $image_gallery->getFile())->resize(100, 100); ?>" alt="<?php echo $_product->getName()?>" />

<?php endforeach; ?>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.