0
votes

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!

1

1 Answers

0
votes

I figured out the solution to this. I just need to add a conditional around the code that displays the image. In the conditional I can access the label by calling $_image->label. Like so:

<?php foreach ($this->getGalleryImages() as $_image): ?>
    <?php if ($_image->label == 'somelabel'):
        <?php // code to display the images ?>
    <?php endif; ?>
<?php endforeach; ?>