how to create a video gallery using video lightbox in magento

how to create a video gallery using video lightbox in magento

September 30, 2026 · Illustrated author avatarBy Stefan Bogdanescu
how to create a video gallery using video lightbox in magento

Creating a Video Gallery with Video Lightbox in Magento

Creating a video gallery for your Magento store can be achieved using the built-in media functionality along with some customization. In this guide, I’ll walk you through the process of setting up a category page with thumbnails that open videos in a lightbox pop-up.

Step 1: Upload Videos and Create Thumbnails

First, upload all your videos to the Magento Media Gallery. You can do this by navigating to Content > Media. Ensure each video is correctly named and organized for easy identification later on.

Next, create thumbnail images for each video file. These thumbnails will be used in the gallery. Make sure they are sized appropriately (around 200x150 pixels) as they will be displayed alongside other products.

Step 2: Create a New Category

If you haven’t already, create a new category where your video gallery will reside. Go to Products > Categories, click the “Add Root Category” button, and provide it with an appropriate name like “Video Gallery”.

You can also add sub-categories if required.

Step 3: Customize the Category View

Now we need to customize the view of this category page to display our video thumbnails instead of regular products. This involves some custom layout updates.

Navigate to Content > Design > Configuration, then select your store view, scroll down to “Layouts” and click on “Add Layout Update”.

In the “Update XML” field, add the following code:

<reference name="catalog_category_view_type_wholesale">
  <action method="setTemplate">
    <template>catalog/category/view.phtml</template>
  </action>
  <block type="core/text_list" name="category.videos.list" before="-">
    <action method="setOutputType">
      <outputType>text/html</outputType>
    </action>
    <block type="catalog/video_gallery" template="catalog/video_gallery.phtml"/>
  </block>
</reference>

This tells Magento to replace the default category view with a custom one that includes our video gallery block.

Next, we need to create the video_gallery.phtml file. In your root directory, navigate to:

app/design/frontend/your_package/your_theme/template/catalog/

If this folder doesn’t exist, you’ll need to create it. Then, inside this folder, create a new file called video_gallery.phtml.

Add the following code to this file:

<?php foreach ($this->getVideos() as $video): ?>
  <div class="video-thumbnail">
    <a href="<?php echo Mage::helper('catalog/image')->init($video, 'image') ?>" data-fancybox-group="gallery" data-caption="<?php echo $video->getTitle(); ?>">
      <img src="<?php echo $this->helper('catalog/image')->init($video, 'thumbnail')->resize(200, 150)->__toString() ?>" alt="<?php echo $video->getTitle(); ?>">
    </a>
  </div>
<?php endforeach; ?>

This code will loop through each video in the category and display it as a thumbnail with a lightbox link.

Step 5: Include FancyBox

To make our thumbnails open videos in a pop-up, we need to include the FancyBox library. You can download this from [https://fancyapps.com/fancybox/3/].

Upload the jquery.fancybox.min.js and jquery.fancybox.min.css files to your theme’s JavaScript and CSS folders respectively.

In your theme’s template file (usually located at app/design/frontend/your_package/your_theme/template/page/html/header.phtml), add the following lines inside the <head> section:

<link rel="stylesheet" href="<?php echo $this->getSkinUrl('js/jquery/fancybox/jquery.fancybox.min.css') ?>">
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/jquery/fancybox/jquery.fancybox.min.js') ?>"></script>

Save all your files and clear the Magento cache. Then, navigate back to your video category page.

You should now see a gallery of video thumbnails that open the corresponding videos in a FancyBox pop-up when clicked.

Conclusion

Creating a video gallery with a lightbox effect in Magento involves some basic layout customization and template creation. By following these steps, you can easily add a professional touch to your store’s media section without needing extensive coding knowledge.

For more advanced customizations or if you run into any issues, consider reaching out to the professionals at Laravel Company, who specialize in Magento development and can provide expert solutions tailored to your needs.

Catalog Themes Configuration CLI

Our network