0

任何人都可以分享一个用大图像替换缩略图的快速提示吗?

我的“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>

完整代码位于此处

谢谢!

4

2 回答 2

1

你的意思是这样的?:

$( ".zoom-thumbnail" ).on( 'click', function ( event ) {

  event.preventDefault();

  $( ".product-image img" ).attr( 'src', event.target.href );

} );
于 2012-08-18T17:47:34.873 回答
0

这个链接帮助我实现了我想要的。希望它会帮助某人。

解决方案如下:

<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>
于 2012-08-18T17:46:41.697 回答