Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gabelloyd/e813d634ad1d705485bffbf2f148fdcc to your computer and use it in GitHub Desktop.
Save gabelloyd/e813d634ad1d705485bffbf2f148fdcc to your computer and use it in GitHub Desktop.
Set a WooCommerce custom default thumbnail and avoid mixed-content errors with SSL
/**
* Change default thumbnail
* @since 1.0
* @author Gabe Lloyd
* ref: https://core.trac.wordpress.org/ticket/25449
*/
add_action( 'init', 'custom_fix_thumbnail' );
function custom_fix_thumbnail() {
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src( $src ) {
$upload_dir = wp_upload_dir();
$baseurl = untrailingslashit( $upload_dir['baseurl'] );
$set_url_scheme = set_url_scheme( $baseurl ); // this is required to avoid mixed-content errors on SSL installs
$src = $set_url_scheme . '/2017/04/coming-soon.png'; // replace this with the image you want to use
return $src;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment