首页 > 解决方案 > WooCommerce - 产品图像模板 - 更改目录路径图像

问题描述

我想更改图像的目录路径。当前的 product-image.php woocommerce 模板是:

    <?php

    if( has_post_thumbnail() ) {

    $image              = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
    $image_title        = esc_attr( get_the_title( get_post_thumbnail_id() ) );
    $image_link         = wp_get_attachment_url( get_post_thumbnail_id() );
    list( $magnifier_url, $magnifier_width, $magnifier_height ) = wp_get_attachment_image_src( get_post_thumbnail_id(), "shop_magnifier" );

    echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" itemprop="image" class="yith_magnifier_zoom woocommerce-main-image" title="%s">%s</a>', $magnifier_url, $image_title, $image ), $post->ID );

} else {
    echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" itemprop="image" class="yith_magnifier_zoom woocommerce-main-image"><img src="%s" alt=" ' . esc_attr__( 'Placeholder', 'jico' ) . ' " /></a>', $placeholder, $placeholder ), $post->ID );
}

    ?>

如何自定义%sin img src="%s"

有人可以帮助我获得一些方向吗?

标签: phpwordpresswoocommercehook

解决方案


$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
echo $image[0]

推荐阅读