Try the Demo

Magento

eCommerce Software for Online Growth

Magento Forum

Our new hosted solution for small & emerging businesses
   
Page 1 of 4
Product Image Pop-Up / Disable Image Zoom
 
kullysupply
Member
 
Avatar
Total Posts:  48
Joined:  2008-08-05
 

I’ve seen a few posts regarding disabling or modifying the image zoom feature. Here’s what I did - I wanted the product image to show up, without the zoom, a certain size and allow users to view the full size image in a new window if they need more detail:

Original code in template/catalog/product/view/media.phtml:

<?php $_product $this->getProduct() ?>
<?php 
if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
<class="product-image product-image-zoom">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</
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: ?>
<class="product-image">
    <
img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(265); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</
p>
<?php endif; ?>

New, simplified code:

<?php $_product $this->getProduct() ?>
<class="product-image">
    <
a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=520,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
    </
a>
</
p>

Notice I removed the “product-image-zoom” class. I also removed the if/else since it didn’t seem necessary anyway. Now, the product image shows up no larger than 250x250 pixels. One click on the image will show the full size picture. This new code is nothing special, but I like having a pop-up window to show details rather than using the image zoom feature.

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

@kullysupply, nice post!

I´ll try and I hope it works to me.

The true is, I don´t like the image zoom feature of Default theme. I mean, it´s not 100% as clean and cool as another Magento´s features.

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
oakRunk
Sr. Member
 
Total Posts:  117
Joined:  2008-09-15
 

I am trying to do the exact opposite grin I want to disable the pop up window while keep the zoom.

I replaced this code:

<a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=520,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">

With this:

<a 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;">

Now my small images do not pop up but rather get displayed in the larger image box...but if I double click on the large image it still pops up. Any help on disabling the pop up?

 Signature 

FUN

 
Magento Community Magento Community
Magento Community
Magento Community
 
oakRunk
Sr. Member
 
Total Posts:  117
Joined:  2008-09-15
 

(edit) whoops...double posted =)

 Signature 

FUN

 
Magento Community Magento Community
Magento Community
Magento Community
 
doctorlogos
Sr. Member
 
Avatar
Total Posts:  178
Joined:  2008-05-06
 

@oakRunk, very interesting!

I want to know too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cavamondo
Sr. Member
 
Total Posts:  80
Joined:  2008-02-02
 

Here is the complete code for: app\design\frontend\default\blank\template\catalog\product\view\media.phtml

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * Product media data template
 *
 * @see Mage_Catalog_Block_Product_View_Media
 */
?>



<?php $_product 
$this->getProduct() ?>
<?php 
if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
<class="main-product-img">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</
p>
<?php else: ?>
<img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(300, 408); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
<?php endif; ?>
<?php 
if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <
ul>
    
<?php foreach ($this->getGalleryImages() as $_image): ?>
        
<li>
            <
a href="[removed]void(0)" onClick="document.getElementById('image').src = '<?php echo $_image->getUrl(); ?>';">
                <
img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(80, 109); ?>" width="80" height="109" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/>
            </
a>
        </
li>
    
<?php endforeach; ?>
    
</ul>
</
div>
<?php endif; ?>
<div id="controlbar" class="highslide-overlay controlbar">
    <
a href="#" class="previous" onclick="return hs.previous(this)" title="Previous (left arrow key)"></a>
    <
a href="#" class="next" onclick="return hs.next(this)" title="Next (right arrow key)"></a>
    <
a href="#" class="highslide-move" onclick="return false" title="Click and drag to move"></a>
    <
a href="#" class="close" onclick="return hs.close(this)" title="Close"></a>
</
div>

I also changed the:

<a href="#" onClick
.. to
<a href="[removed]void(0)" onClick
.. the # made the page scroll to top on each click ...

 
Magento Community Magento Community
Magento Community
Magento Community
 
n20capri
Member
 
Total Posts:  42
Joined:  2008-11-01
Bensalem PA
 

Nice mod thanks - I wanted “more views” though so here is what I did.

<?php $_product $this->getProduct() ?>
<class="product-image">
    <
a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=480,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
    </
a>
</
p
<
class="a-center" id="track_hint"><?php echo $this->__('Click on above image to view full picture'?></p>
<
div class="more-views">
    <
h4><?php echo $this->__('More Views'?></h4>
    <
ul>
    
<?php foreach ($this->getGalleryImages() as $_image): ?>
        
<li>
            <
a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(120); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
        </
li>
    
<?php endforeach; ?>
    
</ul>
</
div>

 Signature 

Mike
http://www.mikemartinelli.com
http://www.baldguydesigns.net

 
Magento Community Magento Community
Magento Community
Magento Community
 
Robert H
Member
 
Avatar
Total Posts:  38
Joined:  2008-11-16
 
oakRunk - 28 October 2008 06:06 PM

I am trying to do the exact opposite :-) I want to disable the pop up window while keep the zoom.

I replaced this code:

<a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=520,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">

With this:
<a 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;">

Now my small images do not pop up but rather get displayed in the larger image box...but if I double click on the large image it still pops up. Any help on disabling the pop up?

what document/line is that in? I could not find it in my media.phtml file. See below.
I am trying to keep the zoom and remove the pop up. I want the images to display in the larger photo area.

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   design_blank
 * @package    Mage
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */

/**
 * Product media data template
 *
 * @see Mage_Catalog_Block_Product_View_Media
 */
?>



<?php $_product 
$this->getProduct() ?>
<?php 
if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
<class="main-product-img">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</
p>
<?php else: ?>
<img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(300, 408); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
<?php endif; ?>
<?php 
if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
    <
ul>
    
<?php foreach ($this->getGalleryImages() as $_image): ?>
        
<li>
            <
a href="[removed]void(0)" onClick="document.getElementById('image').src = '<?php echo $_image->getUrl(); ?>';">
                <
img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(80, 109); ?>" width="80" height="109" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/>
            </
a>
        </
li>
    
<?php endforeach; ?>
    
</ul>
</
div>
<?php endif; ?>
<div id="controlbar" class="highslide-overlay controlbar">
    <
a href="#" class="previous" onclick="return hs.previous(this)" title="Previous (left arrow key)"></a>
    <
a href="#" class="next" onclick="return hs.next(this)" title="Next (right arrow key)"></a>
    <
a href="#" class="highslide-move" onclick="return false" title="Click and drag to move"></a>
    <
a href="#" class="close" onclick="return hs.close(this)" title="Close"></a>
</
div>

 
Magento Community Magento Community
Magento Community
Magento Community
 
oakRunk
Sr. Member
 
Total Posts:  117
Joined:  2008-09-15
 

^ That is different than my media file so I don’t know where to tell you to look.

 Signature 

FUN

 
Magento Community Magento Community
Magento Community
Magento Community
 
elfling
Guru
 
Avatar
Total Posts:  739
Joined:  2008-10-21
 

@Envee

<a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=480,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
    </
a>

Replace with this

<img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />

This will remove the abiity for your top image to pop out

 
Magento Community Magento Community
Magento Community
Magento Community
 
infinitegrace
Jr. Member
 
Total Posts:  8
Joined:  2009-02-22
 

Thanks, this works great.

Is there any way to have a <-previous next-> link added to the thumbnails popup.

Say I have four images under “more views” they click the first thumbnail, is there a way to add links to the next three.

This way they wouldn’t have to close the window, click the next one and so forth…

 
Magento Community Magento Community
Magento Community
Magento Community
 
infinitegrace
Jr. Member
 
Total Posts:  8
Joined:  2009-02-22
 

Ok, slight change to what I said above. I see that this already works.

But… I changed the popup to be the same as the large image (no header, navigation, etc...) and when I did that the next prev links disappeared.

So I guess my question now, is how do I make the popup box for the thumbnails looks the same as the popup for the large image, but include the next prev links?

 
Magento Community Magento Community
Magento Community
Magento Community
 
BungleFeet
Jr. Member
 
Total Posts:  26
Joined:  2008-08-20
 
kullysupply - 14 October 2008 07:54 AM

I’ve seen a few posts regarding disabling or modifying the image zoom feature. Here’s what I did - I wanted the product image to show up, without the zoom, a certain size and allow users to view the full size image in a new window if they need more detail [...]
[...] Notice I removed the “product-image-zoom” class. I also removed the if/else since it didn’t seem necessary anyway. Now, the product image shows up no larger than 250x250 pixels. One click on the image will show the full size picture. This new code is nothing special, but I like having a pop-up window to show details rather than using the image zoom feature.

Nice patch, thanks very much!

Bungle

 
Magento Community Magento Community
Magento Community
Magento Community
 
PattyR
Jr. Member
 
Total Posts:  13
Joined:  2008-08-13
 

Your code worked perfectly, but I would like my image to open in the lightbox rather than the pop-up window.  I have already installed the lightbox and my thumbnails open in the lightbox, but Im not sure how to get the main image to open in the lightbox.

Any ideas would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mexx
Member
 
Avatar
Total Posts:  35
Joined:  2007-09-04
Germany
 
kullysupply - 14 October 2008 07:54 AM

New, simplified code:

<?php $_product $this->getProduct() ?>
<class="product-image">
    <
a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=520,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
    </
a>
</
p>

Notice I removed the “product-image-zoom” class. I also removed the if/else since it didn’t seem necessary anyway. Now, the product image shows up no larger than 250x250 pixels. One click on the image will show the full size picture. This new code is nothing special, but I like having a pop-up window to show details rather than using the image zoom feature.

Thx for that code snippet. Helped me a lot!

 Signature 

I love my work, I could sit and watch it all day long. wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
bigtime
Jr. Member
 
Total Posts:  3
Joined:  2009-04-30
 

Hello,
This works great but the pop-up image is left. Is there anyway to center the popup image?

kullysupply - 14 October 2008 07:54 AM

I’ve seen a few posts regarding disabling or modifying the image zoom feature. Here’s what I did - I wanted the product image to show up, without the zoom, a certain size and allow users to view the full size image in a new window if they need more detail:

Original code in template/catalog/product/view/media.phtml:

<?php $_product $this->getProduct() ?>
<?php 
if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
<class="product-image product-image-zoom">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</
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: ?>
<class="product-image">
    <
img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(265); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
</
p>
<?php endif; ?>

New, simplified code:
<?php $_product $this->getProduct() ?>
<class="product-image">
    <
a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image') ?>', 'gallery', 'width=520,height=520,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
    <
img id="image" src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(250,250); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" />
    </
a>
</
p>

Notice I removed the “product-image-zoom” class. I also removed the if/else since it didn’t seem necessary anyway. Now, the product image shows up no larger than 250x250 pixels. One click on the image will show the full size picture. This new code is nothing special, but I like having a pop-up window to show details rather than using the image zoom feature.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 4
 
© Copyright Magento Inc.
Privacy Policy|Terms of Service
Magento Community Count
819302 users|732 users currently online|519712 forum posts