Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27204

    Hi there, I have a few products that don’t have a product image (yet) or in some cases will never have one.

    Unfortunately the theme does not have a placeholder image and the product catalog looks strange when it’s got the products next to one another and then a gap.

    Is there a workaround for getting a placeholder image?

    #133162

    Hi eakozel,

    Try adding this function to the bottom of your functions.php file and define your placeholder with it:

    /*
    * goes in theme functions.php or a custom plugin. Replace the image filename/path with your own :)
    *
    **/
    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();
    $uploads = untrailingslashit( $upload_dir['baseurl'] );
    $src = $uploads . '/2012/07/thumb1.jpg';

    return $src;
    }
    }

    You just need to replace /2012/07/thumb1.jpg with the route to your image in your uploads folder. So something like /2013/08/yourimagename.jpg .

    Regards,

    Devin

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce product without a product image’ is closed to new replies.