Skip to content

Instantly share code, notes, and snippets.

@bmakowski
Created October 25, 2016 11:33
Show Gist options
  • Save bmakowski/dd5d1b3f2c9dbad1c339c622ff81754a to your computer and use it in GitHub Desktop.
Save bmakowski/dd5d1b3f2c9dbad1c339c622ff81754a to your computer and use it in GitHub Desktop.
WooCommerce Custom Placeholder Image
<?php
/*
Custom Placeholder Image - shows when product hasn't got an image
Author: Bartek Makowski
*/
//inside wp-content/themes/{template}/functions.php
add_action('init', 'custom_fix_thumbnail');
function custom_fix_thumbnail() {
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src($src) {
$upload_dir = wp_upload_dir();
$uploads = untrailingslashit($upload_dir['baseurl']);
//put your own path here
$src = $uploads . '/2014/01/no-image-product.jpg';
return $src;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment