/   /   /  Magento 2 Snippet: Get Just Videos from products gallery

Note:

For more extensions and themes visit our store

Magento 2 Snippet: Get Just Videos from products gallery


Your block is \Magento\Catalog\Block\Product\View\Gallery
inside your template gallery.phtml:

  1.  
  2. $jsonGallery = $block->getGalleryImagesJson();
  3. $arrayJsonGallery = json_decode($jsonGallery, true);
  4. $newArrayJsonGallery = array();
  5. <?php foreach ($arrayJsonGallery as $_image): ?>
  6.           <?php if($_image['type'] != 'video'): ?>
  7.                  <?php $newArrayJsonGallery[] =  $_image ;?>
  8.          <?php endif; ?>
  9. <?php endforeach; ?>
  10.  

Done

Comments

Related Posts

make your store more efficient

Solving problems. With open source technology. Professional results. That’s what makes Ibnab your best choice

IBNAB is a company made of a group of professionals whose work is providing secure open source solutions. Our company strives for reaching magnificent results with each experience and provides professional open source solutions that cover every part of the business process.