简体   繁体   English

Woocommerce产品图库图像显示为全尺寸图像,而不是缩略图

[英]Woocommerce product gallery images are showing as full size images instead of thumbnail

The current Woocommerce setup of this website is being provided with a main product image and several gallery images as normal. 该网站当前的Woocommerce设置正常提供有主要产品图片和一些画廊图片。 The main product image is being used correctly so that it is shown within a list and once clicked, the product page is opened. 主产品图像使用正确,因此将其显示在列表中,并且单击该产品图像后,将打开产品页面。 However, within this product page, the gallery images that are provided on Woocommerce are being shown as full size images beneath each other on the right side of the screen. 但是,在此产品页面中,在Woocommerce上提供的画廊图像在屏幕的右侧以彼此下面的全尺寸图像显示。 Within each product page there is mCustomScrollbar in action so that clients can scroll down the images. 每个产品页面中都有一个运行中的mCustomScrollbar,以便客户端可以向下滚动图像。 I want those to be small images with a lightbox and zoom technique instead of full size images. 我希望这些是具有灯箱和缩放技术的小图像,而不是全尺寸图像。 I have also tested plugins to see whether there are issues with regards to this however none have resulted. 我还测试了插件,以查看是否存在与此相关的问题,但均未解决。

I have created a new local site to test and created a product from scratch to match the original Woocommerce files with these ones since this has gone through a different developer. 我已经创建了一个新的本地站点来进行测试,并从头开始创建了一个产品,以将原始Woocommerce文件与这些文件进行匹配,因为这已经通过了另一个开发人员。 The following files, which seem to be in direct relation with each product page, are binary equal: product-thumbnails.php, product-image.php, single-product.php, content-product.php and content-single-product.php and therefore no changes were made in these that reflect in each product page. 以下文件似乎与每个产品页面都有直接关系,它们是二进制相等的:product-thumbnails.php,product-image.php,single-product.php,content-product.php和content-single-product。 php,因此未对这些内容进行任何更改以反映在每个产品页面中。 I have also found and optimized the below code put in functions.php however to no avail. 我也发现并优化了下面的代码,这些代码放在functions.php中,但无济于事。

 add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs', 5);
 function wps_add_extra_product_thumbs() {

     if (is_product()) {

         global $product;

         $attachment_ids = $product->get_gallery_image_ids();

         echo '<div class="product-thumbs">';

         foreach( array_slice( $attachment_ids, 0,3 ) as $attachment_id ) {

               $thumbnail_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail' )[0];

               echo '<img class="thumb" src="' . $thumbnail_url . '">';

         }

         echo '</div>';

     }

  }

I have already put my head around this and found myself in a loop, however the above is what I have come up with, which up until now is not a solution. 我已经解决了这个问题,发现自己陷入了一个循环,但是以上就是我所想的,到目前为止,这还不是解决方案。 I want the product to show similar to this: https://www.wpstud.io/wp-content/uploads/2016/05/product-with-thumbs.jpg . 我希望产品显示类似以下内容: https : //www.wpstud.io/wp-content/uploads/2016/05/product-with-thumbs.jpg The client's website is fully functional and through the busiest days of the year so I require the most efficient solution without making any major changes. 客户的网站可以正常运行,并且在一年中最繁忙的日子里都可以正常运行,因此我需要最有效的解决方案,而无需进行任何重大更改。 Thanks so much in advance. 非常感谢。

尝试去自定义-> WooCommerce->产品目录并在那里更改图像大小

In addition to the above code previously provided, I have edited some small details from it and also included the Flexslider 2 by implementing the slider's javascript, creating <li> tags within the foreach loop attached with the data-thumb technique (a Flexslider speciality). 除了之前提供的上述代码之外,我还从中编辑了一些小细节,并通过实现滑块的javascript,在Flexslider 2中添加了Flexslider 2,并在附加了data-thumb技术的foreach循环中创建了<li>标签(Flexslider专长) 。 The Flexslider automatically notes the <div> tag holding all <li> tags and voila', perfect execution as intended. Flexslider会自动记录<div>标记,其中包含所有<li>标记和“瞧”,可以按预期完美执行。

Some tweaks here and there to make it work but worth it, client is super happy with this update. 到处进行一些调整以使其正常运行,但是值得,客户端对此更新感到非常满意。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM