【问题标题】:Change the image dimension on the woocommerce product page更改 woocommerce 产品页面上的图像尺寸
【发布时间】:2015-01-04 05:20:55
【问题描述】:

我从这个帖子 Woocommerce: Featured image different than product image 中获得灵感,并将画廊页面之一作为 Woocommerce 主题网站产品页面上的特色图片/大图片。

但是,由于它是从缩略图库中挑选小图像,因此尺寸不会改变,因此图像会变得模糊。其中的 HTML 限制了它。如何增加产品单页主图/大图的宽度和高度。

作为参考,您可以访问此链接http://fliptales2.davcommdev.com/product/aaron-camel/。你会发现图片很模糊,这个大图的 HTML 是 200x159。

【问题讨论】:

    标签: woocommerce


    【解决方案1】:

    无论如何我都完成了。以下是代码.. (with ref: to Woocommerce: Featured image different than product image)

    <div class="images">
    
    <?php
    
        $attachment_ids = $product->get_gallery_attachment_ids();
        isset ($placeholder_width)? : $placeholder_width=0;
        isset ($placeholder_height)? : $placeholder_height=0;
    
        if ( $attachment_ids ) {
            $attachment_id = $attachment_ids[0];
    
        if ( ! $placeholder_width )
            $placeholder_width = $woocommerce->get_image_size( 'shop_catalog_image_width' );
        if ( ! $placeholder_height )
            $placeholder_height = $woocommerce->get_image_size( 'shop_catalog_image_height' );
    
            $output = '<div class="imagewrapper">';
    
            //$classes = array( 'imagewrapper' );
            $classes = array();
            $image_link = wp_get_attachment_url( $attachment_id );
    
            if ( $image_link ) {
    
            $image       = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
            $image_class = esc_attr( implode( ' ', $classes ) );
            $image_title = esc_attr( get_the_title( $attachment_id ) );
    
            echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s"  rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_title, $image ), $post->ID );
    
            } else {
    
                echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="Placeholder" />', woocommerce_placeholder_img_src() ), $post->ID );
    
            }
    
        }
    ?>
    
    <?php do_action( 'woocommerce_product_thumbnails' ); ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-23
      • 2017-02-01
      • 2019-02-11
      • 2022-01-26
      • 2016-05-16
      • 1970-01-01
      • 2015-03-24
      • 2015-08-08
      相关资源
      最近更新 更多