确保您已经安装了 fancybox 插件以及任何依赖项,即鼠标滚轮。
最好将这些包含在您的 local.xml (app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/local.xml) 中,例如:
<?xml version="1.0"?>
<catalog_product_view>
<reference name="head">
<action method="addItem"><type>skin_js</type><name>js/fancybox/jquery.mousewheel-3.0.4.pack.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/fancybox/jquery.fancybox-1.3.4.patch.js</name></action>
<action method="addItem"><type>skin_css</type><name>js/fancybox/jquery.fancybox-1.3.4.css</name></action>
</reference>
</catalog_product_view>
将 app.js 复制到您的主题中(维护目录结构),然后添加/编辑以下内容:
image.elevateZoom({
gallery:'gallery_01',
cursor: 'pointer',
galleryActiveClass: 'active',
imageCrossfade: true,
loadingIcon: 'http://www.elevateweb.co.uk/spinner.gif'
});
将 media.phtml 复制到您的主题中(维护目录结构),以便它使用包含 div 的画廊组,紧随其后的是包含必要数据属性的锚标记,如下所示(从第 67 行开始):
<div class="more-views">
<div class="product-image-thumbs" id="gallery_01">
<?php $i=0; foreach ($this->getGalleryImages() as $_image): ?>
<?php
if (($filterClass = $this->getGalleryFilterHelper()) && ($filterMethod = $this->getGalleryFilterMethod()) && !Mage::helper($filterClass)->$filterMethod($_product, $_image)):
continue;
endif;
?>
<?php $galImg = $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(800); ?>
<a class="thumb-link" href="#" data-image="<?php echo $galImg; ?>" data-zoom-image="<?php echo $galImg; ?>">
<img id="img_<?php echo $i; ?>" src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(75); ?>"
width="75" height="75" alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>" />
</a>
<?php $i++; endforeach; ?>
</div>
在 media.phtml 中更改标记后,您可能必须应用 css