0

I have some product images that should not be displayed in the main product image gallery in magento. I have given a specific label to the images that should not be displayed in the gallery but I am unsure of how to filter the images based on the label.

In my catalog/product/view/media.phtml file I have the following code:

<?php foreach ($this->getGalleryImages() as $_image): ?>
  <?php // code to display the images ?>
<?php endforeach; ?>

I would like to filter the array of images returned from the getGalleryImages() call before looping over them in the template. Is there are easy way to get the label of each of the images and then filter based on the value of the label?

Thanks in advance!

4

1 回答 1

0

我想出了解决方案。我只需要在显示图像的代码周围添加一个条件。在有条件的情况下,我可以通过调用 $_image->label 来访问标签。像这样:

<?php foreach ($this->getGalleryImages() as $_image): ?>
    <?php if ($_image->label == 'somelabel'):
        <?php // code to display the images ?>
    <?php endif; ?>
<?php endforeach; ?>
于 2013-09-11T12:56:47.793 回答