【问题标题】:WooCommerce - Product Image template - change the dir path imageWooCommerce - 产品图片模板 - 更改目录路径图片
【发布时间】:2020-04-18 15:38:12
【问题描述】:

我想更改图像的 dir 路径。当前的 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 );
}

    ?>

如何在img src="%s" 中自定义%s

有人可以帮我找到方向吗?

【问题讨论】:

    标签: php wordpress woocommerce hook


    【解决方案1】:
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
    echo $image[0]
    

    【讨论】:

      猜你喜欢
      • 2019-08-09
      • 2016-09-10
      • 1970-01-01
      • 2021-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-10
      • 2013-07-05
      相关资源
      最近更新 更多