Note: This has been tested on Magento 1.4.2.0
No popup window with the image nor the single image alone in the same page.
If you want to replace the large image with the image displayed in the thumbnail when these are clicked, here are the steps to do it:
- Edit the file media.phtml that you will find in app/design/frontend/[YOUR TEMPLATE]/default/template/catalog/product/view/
- In the final line add a new one and copy/paste the following code:
<script type="text/javascript"> function imageReplace(newimageURL){ document.getElementById("pimage").setAttribute('src', newimageURL); document.getElementById("pimage").style.width = '100%'; } </script>
- Approximately, on line 62 you will find the following code:
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(425).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'"/>';
Simply add id=”pimage” to the img tag or if preferred replace the whole as follows:
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(425).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" id="pimage" />';
- Approximately, on line 73 you will need to change the onclick action of the a href to call the new javascript function that we added in the step 2.
Replace:<a href="#" onclick="imageReplace('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>')" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"> <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /> </a>
With:
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
Temgra’s Color All
If you are using Temgra’s Color All with Magento, the solution that you are requiring is a bit different.
- Edit the file media.phtml that you will find in app/design/frontend/[YOUR TEMPLATE]/default/template/colorall/
- Approximately, on line 54:
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
Replace it with:
<a href="#" onclick="imageReplace('<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>')" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
- In the final line add a new one and copy/paste the following code:
<script type="text/javascript"> function imageReplace(newimageURL){ document.getElementById("image").setAttribute('src', newimageURL); } </script>
Hi Thank you very much for your code for adding product image slide show capability. However is there anyway for it and zoom function to coexist?
For example, when one image is zoomed out using the slider, and I click on the next image thumbnail, the main image changes but remain in the zoomed-in state? Anyway to modify the js so when the thumbnail are click, the main image return to the original size state?
Good question, I’ll take a look on that ASAP. 😉
Hi i When I add more than one image to a product and I click (on the frontend) on the small image beneath the main image it will open in a new window. I’d like to see this image to open in the same place as the main image. and this is a my code in
templatecatalogproductiewmedia.phtml
getProduct();
$_helper = $this->helper(‘catalog/output’);
$confimg = new EM_EvaSettings_EvaSettings();
$w = $confimg->get_base_image_width();
$h = $confimg->get_base_image_height();
$bg = $confimg->get_base_image_bgcolor();
$wt = $confimg->get_thumb_base_width();
$ht = $confimg->get_thumb_base_height();
$bgt = $confimg->get_thumb_base_bgcolor();
?>
getGalleryImages()) > 0): ?>
getGalleryImages() as $_image): ?>
getGalleryUrl($_image));
?>
<a href="#" onclick="popWin('’, ‘gallery’, ‘width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes’); return false;” title=”htmlEscape($_image->getLabel()) ?>”><img style="background-color:” src=”helper(‘catalog/image’)->init($this->getProduct(), ‘thumbnail’, $_image->getFile())->resize($wt,$ht); ?>” width=”” height=”” alt=”htmlEscape($_image->getLabel()) ?>” />
getGalleryImages())>5){?>
Previous
Next
getImage() != ‘no_selection’ && $_product->getImage()): ?>
<?php
$_img = 'helper(‘catalog/image’)->init($_product, ‘image’).'” alt=”‘.$this->htmlEscape($this->getImageLabel()).'” title=”‘.$this->htmlEscape($this->getImageLabel()).'” />’;
echo $_helper->productAttribute($_product, $_img, ‘image’);
?>
__(‘Double click on above image to view full picture’) ?>
<img id="zoom_out" src="getSkinUrl(‘images/slider_btn_zoom_out.gif’) ?>” alt=”__(‘Zoom Out’) ?>” title=”__(‘Zoom Out’) ?>” class=”btn-zoom-out” />
<img id="zoom_in" src="getSkinUrl(‘images/slider_btn_zoom_in.gif’) ?>” alt=”__(‘Zoom In’) ?>” title=”__(‘Zoom In’) ?>” class=”btn-zoom-in” />
//
<?php
$_img = 'helper(‘catalog/image’)->init($_product, ‘image’)->resize($w,$h).'” alt=”‘.$this->htmlEscape($this->getImageLabel()).'” title=”‘.$this->htmlEscape($this->getImageLabel()).'” />’;
echo $_helper->productAttribute($_product, $_img, ‘image’);
?>
please teach me. please. Thank you.
I followed ur code, but it doesn’t work for me. pls help.
In step 4, you reversed the order — I think you meant replace popWin with imageReplace.