Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento how to disable image zoom

Tags:

magento

Does anyone know how to disable the product image zoom in Magento?

like image 518
mcgrailm Avatar asked Aug 14 '10 21:08

mcgrailm


2 Answers

You can modify /catalog/product/view/media.phtml inside your template directory (/app/design/default/your_theme/template). This is the code that outputs the image:

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

The first part (after the if clause) outputs the zoomable image, while the "else" part outputs the non-zoom version. I think the easiest solution is to get rid of the if statement and just leave the non-zoom version:

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

Works like a charm on a fresh installation of magento.

like image 71
silvo Avatar answered Sep 28 '22 03:09

silvo


Disabling the zoom is great if you have low res images. For HD imagaes try to use this plugin, here is an example: http://www.ajax-zoom.com/demo/magento/index.php/chair.html

like image 37
Sven Avatar answered Sep 28 '22 02:09

Sven