WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
get_image() (1 post)

  1. user5674
    Member
    Posted 1 year ago #

    I've recently modified get_image() function to show product titles instead of image's:

    function get_image( $size = 'shop_thumbnail' ) {
        	global $woocommerce;
    
            #$title = array('class' => 'alignleft');
        	$image = '';
    
    		if ( has_post_thumbnail( $this->id ) ) {
    			$image = get_the_post_thumbnail( $this->id, $size, array('title' => the_title_attribute('echo=0')) );
    		} elseif ( ( $parent_id = wp_get_post_parent_id( $this->id ) ) && has_post_thumbnail( $parent_id ) ) {
    			$image = get_the_post_thumbnail( $parent_id, $size, array('title' => the_title_attribute('echo=0')) );
    		} else {
    			$image = '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $woocommerce->get_image_size( 'shop_thumbnail_image_width' ) . '" height="' . $woocommerce->get_image_size( 'shop_thumbnail_image_height' ) . '" />';
    		}
    
    		return $image;
        }

    But now, i'm getting wrong titles in my dropdown cart widget, where product title showing as last blog post at particular page.

    This is row responsible for image:
    echo $_product->get_image();

    I'm out of ideas how to fix it, as far i know get_image() only args is size of image, would be easy if it had title attr as well.

    http://wordpress.org/extend/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.