Skip to main content
Articles

Change the Default WooCommerce Placeholder Permanently

Just a reminder that this can be set programatically. Once this is set, clients can’t change this in the WooCommerce settings either. This is a permanent solution for preventing someone or an update, from modifying the settings.

I recommend adding this as a plugin and not the the functions.php, as it will get overwritten with every theme update.


<?php
/*
 * Plugin Name:       WooPlaceholder
 * Description:       WooPlaceholder
 * Version:           1.00
 * Requires PHP:      7.4
 * Author:            Wally David
 * Text Domain:       wc-woo-placeholder-default
 */

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'] );
  // replace with path to your image
  $src = $uploads . '/2012/07/thumb1.jpg';
   
  return $src;
}

Source “WooCommerce