Created
May 4, 2017 18:08
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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