Sabuj Kundu 13th May 2019

Woocommerce shows product thumbnails for both archive/loop pages and details page. At install woocommerce create a media type post for thumbnail and saves the attachment id in option table for option name woocommerce_placeholder_image. In archive pages like shop page, category page, tags page it displays the thumbnail version of placeholder if no custom image is used as featured image. In product details page it shows the product images in place of product thumb but if there is no product images it will show product thumb or featured image. So, in short in no featured image used in any product it shows the placeholder image, in product details if no product images are added, then it shows the placeholder image but larger size than thumbnail.

As thumb woocommerce displays image’s size woocommerce_thumbnail and in details page “woocommerce_single”.

Using Custom Placeholder Image

What if we want to display custom placeholder image? As woocommerce’s default placeholder image may not fit for your theme.Woocommerce provides two hooks as filter for this. One is for thumbnail version and one is for larger version but a bit in different way.

In loop/archive pages wooocommerce calls the function function wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) to display the thumbnail image markup, if default placeholder media type attachment post is missing then it calls the the thumbnail version function to get the image src function wc_placeholder_img_src($size ) but at last the markup of placeholder image display returns with a filter called return apply_filters( 'woocommerce_placeholder_img', $image_html, $size, $dimensions ); . So, if you want to replace the placeholder thumbnail image html markup you have to add filter to “woocommerce_placeholder_img”

In product details page if product images are missing then default placeholder image is used as single product image and in that case woocommerce calls the function function wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) { which returns only image src (please note there, only image not whole image tag markup like the archive pages) return apply_filters( 'woocommerce_placeholder_img_src', $src );. So if you want to change the default thumbnail version of placeholder image you have to hook “woocommerce_placeholder_img_src”

Unified Custom Placeholder Image

If you use a larger version of thumbnail or photo as placeholder in archive pages same image can be used in product details page also. We can show same custom placeholder image following the below code snippet.