This tutorial provides 2 code snippets which enable you to filter the main product image on the single product page in WooCommerce.
As seen in the demo video, this code can be used to :
- Replace the default image with a custom image when no product image is added.
- Add a custom image which replaces the main image on the single product page so the product image is displayed on all other locations, if added.
- When no product image is added, add a custom image which only displays as the main image on the single product page and the placeholder displays in all other locations.
- Also display the product gallery images when a custom image is added.
- Display a custom placeholder image in all locations when a custom or default image is not added.
Watch Demo Video #
Tested using the Lifestyle Pro child theme by StudioPress however will work in any Genesis or non Genesis child theme.
There’s 2 steps relating to usage of the code in the download folder.
Step 1 : Copy & paste the code from the functions.php to the end of your child themes functions file.