Add YouTube video into the default WooCommerce product gallery
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.
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.