You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"
Does this snippet (still) work?
Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.
Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.
36 thoughts on “WooCommerce: Show Video Instead of Product Images”
Thanks so much for this great resource! I have a problem though. The src URLs are disappearing. I used this code to add an image and video and both src: URLs were removed when I tested it. I also tried placing them in the ‘add_below_prod_gallery’ hook and it did the same thing. The images only show up when I put it in the ‘single_product_summary’ hook.
the URL src looks like this on render.
Thank you for your help!
Can’t really tell from “here”, I’d need to see your plugins/theme setup and see if there is some conflict. iframe should work no problem
Is there any other tuts that show how to use this in addition to using gallery images? Thanks!
This should help https://www.businessbloomer.com/woocommerce-add-content-below-the-single-product-page-images/
Amazing plugin. Simply amazing. However, the product image is coming full width and price and description has gone down.
Please see if any help is possible.
Note I am a young developer…so learning only.
Thank you! You’ll need a bit of CSS to fix that
As I am testing this code with the new default theme of Twenty Twenty Two.
I had to make the iframe video width smaller and adjusted it from 560 to 480. So that I could get the product information beside the video.
I then added this CSS:
Because of these adjustments the video is now seen to the left of the product title, price, short description etc.
Hi, I´d like to show a video in a gallery woocommerce product, but as “normal” image that when you clik on it, it shows int he box where is shown the featured image, not in a fancybox or a popup and without any video icon and in autoplay mode.
Hi Jorge, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
This code is not working for me with a simple product in 4.2.1
Disable all plugins but Woo and switch to 2020 theme, then let me know please
hello! it is possible to make it play automatically and infnite? as a gif?
Yes, just place a GIF image there instead of a video
This works great for the product image!
I’m using the code to insert an iframe of an image hosted on another site.
Is there any way to tweak the code so it also updates the image in the shop page.
I’ve tried to tweak the code but not sure what the hook is called for the other images
Hi Matt, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
How can you include more products ID’s in the code instead of just a single ID?
Hi, This array has to work with multiple youtube links. What modification has to be done in second part of the code to assign respective youtube videos to multiple products. Please help.
Hi Prashant, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
But it removes all the images below the feature image(for variable product), I want to replace the main image by video , but want to have those other images(for variable product) , how can I do that , please explain.
That’s much more complex, sorry
Hi, I want to show video as a product thumbnail in woocommerce,
let me know if you can help me.
No I’m sorry 😐
Muhammad, our free plugin will do this for you. You can also do automated searches for product videos on sites like YouTube, Facebook Videos, Vimeo and more.
Nice tutorial. But it removes the whole photo gallery. Is there any way to integrate the video inside existing gallery?
Hello Aslam, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Would be indeed a great feature!
Thanks for the video, it is amazing and works perfectly fine!
I’m embedding an iFrame API instead of the video, which allows me to customize my WooCommerce products using a third party tool that I call through the iFrame. But, how can I improve the style of this embedded iFrame? For example: center it, separate the “Add to basket” text to another line, etc.
And also, how could I get some parameters from my webpage (like php_session_id) to include them in the iFrame URL?
I’d appreciate if you could give me some guidance about these two topics.
Thanks a lot!
Rodrigo, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
I tried doing this but unfortunately it didn’t work. I just copied the snippet you provide and replace the product ID and the video url. but the video in the product page doesn’t show up, I just get a blank space where the image was.
Alfonso, thanks for your comment! Weird, it works for me – maybe your theme is customizing the way WooCommerce works.
Could you try using priority “30” instead of “20”:
How can I do this in place of a category image on the Storefront Homepage?
CS, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Nice one Rodolfo, although I don’t really like changing an image for an video by programming on a product by product basis (having to change the programming for every new product that needs a vid). The idea of and cms is not having to hardcode content, seperating content control from functionality and presentation.
The next challenge is to make it generic and get the video-url or -id from the post. Perhaps adding a custom field to the product containing the video url or video number? Then the snippet can just test the custom field and only if a video is entered replace the image. It would make the snippet somewhat more complex, but it would be a more generic solution.
It would be nice if wordpress itself allows the featured image to be featured media, then this point is changed structuraly and automatically. Perhaps they will get there at some point.
Hans, thanks for your comment! Positive, the whole snippet can be modified to “get” the value of a custom field, I only published a simple, light-weight solution here 🙂