Rynald0s
(@rynald0s)
Automattic Happiness Engineer
Hi Guido!
The current hook is wc_placeholder_img_src
Cheers!
Thread Starter
Guido
(@guido07111975)
Hi,
Thanks for your response. When I replace the filter with the new one, my code snippet doesn’t work anymore; the default WC placeholder is displayed again.
add_filter('wc_placeholder_img_src', 'wc_custom_placeholder_img');
Guido
I use this and it seems to work:
/**
* xxxxxx FUNCTION TO CHANGE WOOCOMMERCE PLACEHOLDER
*/
// Add action to hook into the approp
add_filter( 'woocommerce_placeholder_img_src', 'growdev_custom_woocommerce_placeholder', 10 );
/**
* Function to return new placeholder image URL.
*/
function growdev_custom_woocommerce_placeholder( $image_url ) {
$image_url = '/placeholderMODIFIED.png'; // change this to the URL to your custom placeholder
return $image_url;
}
Thread Starter
Guido
(@guido07111975)
Hi,
It still does work but filter woocommerce_placeholder_img_src is deprecated and is replaced by wc_placeholder_img_src.
But when I use this new filter in my code snippet, my custom placeholder isn’t displayed anymore:
function wc_custom_thumbnail() {
function wc_custom_placeholder_img( $src ) {
$src = get_stylesheet_directory_uri().'/images/product.jpg';
return $src;
}
add_filter('wc_placeholder_img_src', 'wc_custom_placeholder_img');
}
add_action( 'init', 'wc_custom_thumbnail' );
So the problem is the new filter: wc_placeholder_img_src
Guido
Rynald0s
(@rynald0s)
Automattic Happiness Engineer
Hi Guido!
Just had another look — its actually the woocommerce_placeholder_img_src function that is deprecated, the woocommerce_placeholder_img_src filter still works.
Thread Starter
Guido
(@guido07111975)
Aha, thanks… there was some confusion here (filter vs function) 😉
So I don’t have to update my code snippet anymore. Solved.
Guido