Add YouTube video into the default WooCommerce product gallery

Chelaru Adrian
4 min readJul 13, 2023

If you have a website that uses WooCommerce and don’t want to replace the standard gallery which is delivered with the plugin to add an YouTube video into it, then you can modify it with a few lines of code to support that.

WooCommerce gallery with YouTube video — images are blurred by intention

WordPress and WooCommerce development

7 stories

What this does, exactly

The script will let you insert the YouTube video thumbnail into the main WooCommerce product gallery, while keeping the original featured image.

Video will be open with the Lity in a lightbox.

This will be displayed only on the single product page, and not on the product archive or category.

Implementation

In order to put the play button overlay, you need to install the Material Design Icons for Page Builders plugin and add the CSS from below.

You can skip this if you don’t want the Play button over the video, but I recommend you to remove or alter the div with class youtube-play-button from the functions.php (Code Snippet) part.

--

--

Chelaru Adrian
Chelaru Adrian

Written by Chelaru Adrian

💻 Hey, I'm here to share my passion for tech! 🚩 Follow me on Medium for exciting new ideas and innovative solutions.

Responses (1)