Woocommerce get category image full size

by Sema Hernández   Last Updated March 02, 2018 23:08 PM

i'm trying to get the full size image of my category products.

    $prod_categories = get_terms( 'product_cat', array(
        'orderby'    => 'name',
        'order'      => 'ASC',
        'hide_empty' => true
    ));

    foreach( $prod_categories as $prod_cat ) :
        $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
        $cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id );
        $term_link = get_term_link( $prod_cat, 'product_cat' );?>

        <a href="<?php echo $term_link; ?>"><img src="<?php echo $cat_thumb_url; ?>" alt="<?php echo $prod_cat->name; ?>" /></a>

    <?php endforeach; wp_reset_query();

The above code works, but it returns an image of 150px x 150 even when adjustments in Woocommerce are like this:

My Woocommerce product settings

I´d like to get a larger size or full size. Thanks!



Answers 2


Thanks to Mike Jolley (Woocommerce plugin author) for the solution using: wp_get_attachment_image_src

$prod_categories = get_terms( 'product_cat', array(
        'orderby'    => 'name',
        'order'      => 'ASC',
        'hide_empty' => true
    ));

    foreach( $prod_categories as $prod_cat ) :
        $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
        $shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, 'shop_catalog' );
        $term_link = get_term_link( $prod_cat, 'product_cat' );?>

        <a href="<?php echo $term_link; ?>"><img src="<?php echo $shop_catalog_img[0]; ?>" alt="<?php echo $prod_cat->name; ?>" /></a>

    <?php endforeach; wp_reset_query();
Sema Hernández
Sema Hernández
September 01, 2015 16:11 PM

It´s work fine!! I add a name of category.

    'name', 'order' => 'ASC', 'hide_empty' => true )); foreach( $prod_categories as $prod_cat ) : $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true ); $shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, 'shop_catalog' ); $term_link = get_term_link( $prod_cat, 'product_cat' );?> "> name; ?> " alt="name; ?>" />
eduardo palma
eduardo palma
March 02, 2018 22:36 PM

Related Questions



Keep image EXIF info for resized image uploads?

Updated April 11, 2016 09:03 AM