WooCommerce - 如果 none 则隐藏产品图片

WooCommerce - Hide product images if none

我正在 Bootstrap 中开发一个使用 WooCommerce 的主题。我试图隐藏产品 images/gallery 所在的 col-md-1,如果有 none,并使我的产品图像列从 col-md-5 到 col-md-6

页面设计由3栏组成:

  1. col-md-5 - 产品图片
  2. col-md-1 - 产品 images/gallery
  3. col-md-6 - 产品信息

Here you can see where the product has more images in the col-md-1

Here you see it without product images

这是一个可以帮助您的代码。

jQuery( document ).ready(function(){
if(jQuery('.col-md-1').children().length===0){
jQuery('.col-md-1').css('display','none');
jQuery('.col-md-5').toggleClass('col-md-6');
jQuery('.col-md-5').removeClass('col-md-5');
}
});

首先在浏览器中加载页面,然后在控制台中粘贴以下代码以查看效果。

如果此代码是您想要的,则添加相同的代码以有条件地仅将其加载到单个产品页面上。