1

I am getting all the product images programmatically to create a banner slider from all of them, right now it is showing all the images that are uploaded from the admin to the specific product.

<?php $galleryData = $product->getData('media_gallery');
       $galleries = $galleryData['images'];
         $_media = Mage::getBaseUrl('media');
             foreach($galleries as $gal_images){ ?>
                <?php echo $all_I_mages =  $_media.'catalog/product'.$gal_images['file']; ?>
                    <div style="background-image:url(<?php echo $all_I_mages ?>);  background-position: center center;  background-repeat: no-repeat;
background-size: auto auto; background-color: #efefef; " >
                    </div>
             <?php   } ?>

Now i want to exclude some of the images from this array for example i dont want to include "small image" , "thumbnail" , and "base image"

can anyone guide what check i need to apply to solve this issue

1 Answer 1

1

you can put check something like that.

  if($_product->getThumbnail() != $gal_images['file'] || $_product->getSmallImage() != $gal_images['file'] || $_product->getBaseImage() != $gal_images['file']): ?>
<?php echo $all_I_mages =  $_media.'catalog/product'.$gal_images['file']; ?>
                    <div style="background-image:url(<?php echo $all_I_mages ?>);  background-position: center center;  background-repeat: no-repeat;
background-size: auto auto; background-color: #efefef; " >
                    </div>
<?php
  endif; ?>
16
  • Let me try if it works..
    – Xabby
    Jan 25, 2017 at 9:54
  • Qaisar Satti its not working anything else you can suggest..
    – Xabby
    Jan 25, 2017 at 12:36
  • did you load the product before that? Jan 25, 2017 at 12:37
  • yes i did : <?php $_product = Mage::registry('current_product')->getId(); $product = Mage::getModel('catalog/product')->load($_product); ?>
    – Xabby
    Jan 25, 2017 at 12:41
  • @Xabby use and condition or nested it then it work for you Jan 25, 2017 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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