WooCommerce 3.0にアップデートしてもテーマが更新されていない場合、WooCommerce 3.0単一製品イメージギャラリーを以前のバージョンと同じように機能させるにはどうすればよいですか?WooCommerce 3.0 Single Image Galleryをバージョン2.xのようにするにはどうすればいいですか?
されたテンプレートファイルをコピーして、多くの問題を回避するために変更する条件文、フック、およびフィルタを使用しないでくださいテーマについて質問です。
WooCommerce 3.0にアップデートしてもテーマが更新されていない場合、WooCommerce 3.0単一製品イメージギャラリーを以前のバージョンと同じように機能させるにはどうすればよいですか?WooCommerce 3.0 Single Image Galleryをバージョン2.xのようにするにはどうすればいいですか?
されたテンプレートファイルをコピーして、多くの問題を回避するために変更する条件文、フック、およびフィルタを使用しないでくださいテーマについて質問です。
新WooCommerce単一製品のギャラリー機能のテーマのサポートを追加するには、子テーマであなたのfunctions.phpファイルに追加します。
add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
add_theme_support('wc-product-gallery-slider');
add_theme_support('wc-product-gallery-slider');
負荷FlexSliderを使用します。私の最後にJSの問題がなければ、私の製品イメージがまったく同じサイズでないときは、読み込み時の高さが間違っています。 SmoothHeightはfalseです。フィルターがオンになっていても、大きなギャップがあります。まったく、ChromeとFireFoxの両方でこの問題は解決されません。
したがって、(とにかくスライダーを持っていなかった)2.6と同様の機能を得るための簡単な方法が、より良いライトボックスで、唯一、次のテーマのサポートを追加します。次に
add_theme_support('wc-product-gallery-zoom');
add_theme_support('wc-product-gallery-lightbox');
をshop_thumbnailサイズを使用するようにサムネイル画像をフィルタリング:次に
/**
*
* Change Thumbnail Size but run only in the @woocommerce_product_thumbnails hook
*
*/
function yourprefix_single_product_thumbnail_size_filter($html, $attachment_id){
$full_size_image = wp_get_attachment_image_src($attachment_id, 'full');
$thumbnail = wp_get_attachment_image_src($attachment_id, 'shop_thumbnail');
$thumbnail_post = get_post($attachment_id);
$image_title = $thumbnail_post->post_content;
$attributes = array(
'title' => $image_title,
'data-src' => $full_size_image[0],
'data-large_image' => $full_size_image[0],
'data-large_image_width' => $full_size_image[1],
'data-large_image_height' => $full_size_image[2],
);
$html = '<div data-thumb="' . esc_url($thumbnail[0]) . '" class="woocommerce-product-gallery__image"><a href="' . esc_url($full_size_image[0]) . '">';
$html .= wp_get_attachment_image($attachment_id, 'shop_thumbnail', false, $attributes);
$html .= '</a></div>';
return $html;
}
はでそれを適用フック。
function yourprefix_do_single_product_image_size_filter() {
//apply filter
add_filter('woocommerce_single_product_image_thumbnail_html', 'yourprefix_single_product_thumbnail_size_filter', 10, 4);
}
add_action('woocommerce_product_thumbnails', 'yourprefix_do_single_product_image_size_filter');