Last active
May 24, 2024 07:47
-
-
Save braddalton/df2675d6dac3bcb23b723a907dc66345 to your computer and use it in GitHub Desktop.
Use woocommerce_placeholder_img_src filter hook. This is the original function containing the filter. Full Tutorial https://wpsites.net/?p=115999
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
function wc_placeholder_img_src( $size = 'woocommerce_thumbnail' ) { | |
$src = WC()->plugin_url() . '/assets/images/placeholder.png'; | |
$placeholder_image = get_option( 'woocommerce_placeholder_image', 0 ); | |
if ( ! empty( $placeholder_image ) ) { | |
if ( is_numeric( $placeholder_image ) ) { | |
$image = wp_get_attachment_image_src( $placeholder_image, $size ); | |
if ( ! empty( $image[0] ) ) { | |
$src = $image[0]; | |
} | |
} else { | |
$src = $placeholder_image; | |
} | |
} | |
return apply_filters( 'woocommerce_placeholder_img_src', $src ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment