Title: Return Attribute Image
Last modified: December 13, 2018

---

# Return Attribute Image

 *  Resolved [dsm1](https://wordpress.org/support/users/dsm1/)
 * (@dsm1)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/return-attribute-image/)
 * I have this: [https://wordpress.org/plugins/wp-custom-taxonomy-image/](https://wordpress.org/plugins/wp-custom-taxonomy-image/)
   
   And would like to return the image per attribute in it’s own tab, how can I do
   this?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [mjke87](https://wordpress.org/support/users/mjke87/)
 * (@mjke87)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/return-attribute-image/#post-10987995)
 * Hi,
 * It would certainly be possible to display the pictures from the plugin in the
   attributes in the tabs. However, some programming would be required.
 * You could however, display pictures without the need of an additional plugin.
   Simply add the following HTML in the product tab description field to display
   a picture.
 * `<img src="URL-TO-YOUR-PICTURE" style="max-width:100% "/>`
 * You can use any HTML and even Shortcodes in the tab description field. You could
   therefore also use the WordPress native gallery shortcode:
    `[gallery ids="729,732,731,720"]`
 * Cheers,
    Mike
 *  Thread Starter [dsm1](https://wordpress.org/support/users/dsm1/)
 * (@dsm1)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/return-attribute-image/#post-10988015)
 * Thanks Mike,
 * As I’m programming the tabs from the functions.php file and putting a Attributes
   loop in place, are you able to assist me with what code I need to use for an 
   image in the loop please?
 * I have this so far:
 *     ```
       /**
        * Add a custom product data tab
        */
       add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
       function woo_new_product_tab( $tabs ) {
   
           // Adds the new tab
   
           $tabs['test_tab'] = array(
               'title'     => __( 'Ingredients', 'woocommerce' ),
               'priority'  => 50,
               'callback'  => 'woo_new_product_tab_content'
           );
   
           return $tabs;
   
       }
       /**
        * Remove product data tabs
        */
       add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
   
       function woo_remove_product_tabs( $tabs ) {
   
           unset( $tabs['additional_information'] );   // Remove the additional information tab
   
           return $tabs;
       }
       function woo_new_product_tab_content() {
   
           // The new tab content
   
           echo '<h2>List of Ingredients in this product</h2>';
           echo '<p>Here\'s your new product tab.</p>';
           global $product;
       $ingredients_list = $product->get_attribute( 'ingredients' );
           print $ingredients_list;
   
       }
       ```
   
 *  Plugin Author [mjke87](https://wordpress.org/support/users/mjke87/)
 * (@mjke87)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/return-attribute-image/#post-10988056)
 * Hi,
 * Check the readme from the term image plugin:
 * > you can use the following function into your templates to get category/term
   > image:
   >     ```
   >     if (function_exists('get_wp_term_image'))
   >     {
   >         $meta_image = get_wp_term_image($term_id); 
   >     	//It will give category/term image url 
   >     }
   > 
   >     echo $meta_image; // category/term image url
   >     ```
   > 
   > where $term_id is ‘category/term id’
 * Something along these lines:
 *     ```
       $attributes = $product->get_attributes();
       foreach($attributes as $attribute) {
           $terms = wp_get_post_terms($product->get_id(), $attribute['name']);
           foreach ($terms as $term) {
               $meta_image = get_wp_term_image($term->term_id); 
           }
       }
       ```
   
 * Kind regards,
    Mike

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Return Attribute Image’ is closed to new replies.

 * ![](https://ps.w.org/woo-product-attribute-tab/assets/icon-256x256.png?rev=2302212)
 * [Reusable Product Description for WooCommerce](https://wordpress.org/plugins/woo-product-attribute-tab/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-product-attribute-tab/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-product-attribute-tab/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-product-attribute-tab/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-product-attribute-tab/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-product-attribute-tab/reviews/)

## Tags

 * [attributes](https://wordpress.org/support/topic-tag/attributes/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [images](https://wordpress.org/support/topic-tag/images/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 3 replies
 * 2 participants
 * Last reply from: [mjke87](https://wordpress.org/support/users/mjke87/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/return-attribute-image/#post-10988056)
 * Status: resolved