Actually I found this code from here: http://docs.woothemes.com/document/woocommerce-display-category-image-on-category-archive/
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
echo '<img src="' . $image . '" alt="" />';
}
}
}
but I can’t figure out where in there I can set my custom size for it, a different size than listed in WooCommerce Settings > Catalog at the bottom. I’ve created a custom size called ‘feature-image’ in my functions.php using add_image_size. If I can have it just use that image that gets generated I guess I wouldn’t need a second image upload…?
Figured it out.
if (is_product_category()){
global $wp_query;
// get the query object
$cat = $wp_query->get_queried_object();
// get the thumbnail id user the term_id
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
// get the image URL
$image = wp_get_attachment_image( $thumbnail_id, 'feature-image' );
// print the IMG HTML
echo $image;
}
Not a fan of this, though, because I can’t control the crop. So, I am back to needing to upload two thumbnail images in the Category…
Thanks for figuring it out. Exactly what I was looking for.
You shouldn’t need to upload two thumbnail images in the Category. When you upload an image to the Media Library, the default post thumbnail sizes are generated, as well as any custom sizes you included in functions.php.
So you could write ‘wp_get_attachment_image’ again, but change the ‘feature-image’ alias to ‘thumbnail’ (or whatever size you want).