代码之家  ›  专栏  ›  技术社区  ›  mcgrailm

Magento如何禁用图像缩放

  •  6
  • mcgrailm  · 技术社区  · 15 年前

    有人知道如何在Magento中禁用产品图像缩放吗?

    2 回复  |  直到 15 年前
        1
  •  6
  •   silvo    15 年前

    <?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
    <p class="product-image product-image-zoom">
        <?php
            $_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
            echo $_helper->productAttribute($_product, $_img, 'image');
        ?>
    </p>
    <p class="zoom-notice" id="track_hint"><?php echo $this->__('Double click on above image to view full picture') ?></p>
    <div class="zoom">
        <img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" title="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
        <div id="track">
            <div id="handle"></div>
        </div>
        <img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" title="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
    </div>
    <script type="text/javascript">
    //<![CDATA[
        Event.observe(window, 'load', function() {
            product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
        });
    //]]>
    </script>
    <?php else: ?>
    <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; ?>
    

    第一部分(if子句之后)输出可缩放图像,而“else”部分输出非缩放版本。我认为最简单的解决方案是去掉if语句,只保留非缩放版本:

     <?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');
        ?>
    

    就像一个魅力的新安装的magento。

    推荐文章