Sometimes, with new products, you don’t have an image and so WooCommerce uses a placeholder image. With a recent customer, they wanted to show the product’s brand image in these cases. The following code will allow you to display the product’s brand image on the category pages and on the product page as the product image. If a product image is added to the product, then the brand image is no longer displayed as the product image.

Note: This plugin uses the brand image from WooCommerce Perfect Brands.

  1. Create a folder in /wp-content/plugins/ named “woocommerce-brand-image-as-placeholder” and a file inside that named “woocommerce-brand-image-as-placeholder.php”
  2. Past the following code in this file:
 * Plugin Name: WooCommerce Replace Product Placeholder with Brand Image
 * Plugin URI:
 * Description: Replaces product placeholder images with the image of the product brand if the product has no images.
 * Version: 1.0.0
 * Author: DWD
 * Author URI:

// run the function on only product pages and category pages
add_action('init', 'run_brands_on_product_and_categories_only');
function run_brands_on_product_and_categories_only() {
	if ( (!is_admin()) && (is_product() || is_product_category())) {

// Add brand image to products that have no image
function dwd_replace_placeholder_image_with_brand() {
	global $product;

	$productImage = wp_get_attachment_url( $product->get_image_id() );
	if (empty($productImage) && (is_product_category() || is_product())) {
		$productBrands = wp_get_object_terms( $product->get_id(), 'pwb-brand' );

		foreach( $productBrands as $brand ) {
			$brandLogo = get_term_meta( $brand->term_id, 'pwb_brand_image', true );
			$brandLogo = wp_get_attachment_url( $brandLogo );
			return $brandLogo;

3. Activate the plugin.