• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Customize WooCommerce products default image

Learn in this tutorial how to modify the placeholder image used by WooCommerce on products without featured image using code.

If you are used to using WooCommerce you will have noticed that when a featured image is not added to a product, it displays one by default:

Placeholder image in WooCommerce
Default placeholder image in WooCommerce

But you might want to change it to another one.

For example, if you have a mug store, it probably makes more sense to show the following image, since it is more specific.

Custom placeholder image in WooCommerce
Custom placeholder image in WooCommerce.

And here’s how to get it:

Snippet to customize the default image of WooCommerce products

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 847 code snippets of this website, login or subscribe here.

Thanks to the woocommerce_placeholder_img_src filter you can indicate the path of the image you want to use as placeholder or default image.

Just upload the image you want to use, if you haven’t already, and modify the path in the $src line (only the final part '/2022/04/placeholder.svg').

Conclusion

As you can see, with a few lines of code you can customize the default image that WooCommerce uses for products where you have not selected a featured image.

Any questions? Let me know in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

PHP Products WooCommerce

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?