I'm trying to replace single product page gallery images to custom placeholder I have.
I have found this hook:
woocommerce_single_product_image_thumbnail_html
But the hook using the variable $image, which his type is unclear (html string/url).
Also found the following hook wp_get_attachment_image_src to be responsible of the thumbnails image URL source, but it doesn't work.
add_filter( 'wp_get_attachment_image_src', array( $this, 'pn_change_product_image_link'), 50, 4 );
function pn_change_product_image_link( $image, $attachment_id, $size, $icon ){
if( ! is_product() ) return $image; // Only on single product pages
if( $size == 'shop_thumbnail' ) return $image; // Not for gallery thumbnails (optional)
// Your source image link
$new_image_id = 1370;
$src = wp_get_attachment_url( $new_image_id );
$width = ''; // <== (optional) define the width
$height = ''; // <== (optional) define the height
$image = array( $src, $width, $height );
return $image;
}
How can I replace Woocommerce gallery images to custom placeholder image?