有人可以分享快速提示,用大图片替换缩略图吗?
来自'media.phtml'的代码的快速摘录如下:
<p class="product-image">
<?php
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
?>
</p>
<?php endif; ?>
<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
<h2><?php echo $this->__('More Views') ?></h2>
<ul class="cf zoom-gallery">
<?php
foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a class="zoom-thumbnail" style="width:<?php echo $arrMedia ["width"]; ?>px;" class="cloud-zoom-gallery" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($arr ["Owidth"], $arr ["Oheight"]); ?>" target="_popUp" data-easyzoom-source="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($arr ["Owidth"], $arr ["Oheight"]); ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($arrMedia ["width"], $arrMedia ["height"]); ?>" width="<?php echo $arrMedia ["width"]; ?>" height="<?php echo $arrMedia ["height"]; ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
</li>
<?php endforeach; ?>
</ul>
</div>
完整代码位于here
谢谢!
答案 0 :(得分:1)
你的意思是?:
$( ".zoom-thumbnail" ).on( 'click', function ( event ) {
event.preventDefault();
$( ".product-image img" ).attr( 'src', event.target.href );
} );
答案 1 :(得分:0)
This link帮助我实现了我想要的目标。希望它会对某人有所帮助。
解决方案如下:
<a class="zoom-thumbnail" style="width:<?php echo $arrMedia ["width"]; ?>px;" class="cloud-zoom-gallery" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($arrMedia ["width"], $arrMedia ["height"]); ?>" width="<?php echo $arrMedia ["width"]; ?>" height="<?php echo $arrMedia ["height"]; ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>