1

please visit link , product image is serving from cache path :

media/catalog/product/cache/1/image/350x350/9df78eab33525d08d6e5fb8d27136e95/i/m/img26_1.jpg

we want to change to below path.

media/catalog/product/i/m/img26_1.jpg

i am trying following code in media.phtml but its not working for me.

<?php echo formatPath($_img->resize($w, $h)); ?>

media.phtml

<?php 
function formatPath($mediaFile = '')
{
    $main = $mediaFile;

$mainArray = explode('/', $main);
$countArray = count($mainArray);
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$mainArray[$countArray-3].'/'.$mainArray[$countArray-2].'/'.$mainArray[$countArray-1];
}
 ?>

<?php
    $_product = $this->getProduct();
    $_helper = $this->helper('catalog/output');
    $dexxtz = Mage::helper('productzoom');

    $dexxtz->getCss();
    $dexxtz->getJs();
?>

<ul id="etalage">
    <li>                
        <img class="etalage_thumb_image" src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image')); ?>" />
        <img class="etalage_source_image" title="<?php echo $_product->getImageLabel(); ?>" 
        src="<?php echo formatPath($_img->resize($w, $h)); ?>" />

    </li>
    <?php 
        foreach ($this->getGalleryImages() as $_image) {
            if(Mage::registry('current_product')->getImage() != $_image->getFile()) { ?>                
            <li>
                <img class="etalage_thumb_image" 
                src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())); ?>" />
                <img class="etalage_source_image" title="<?php echo $_image->getLabel(); ?>" 
                src="<?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()), true); ?>" />
            </li> 
        <?php 
            }    
        }
    ?>   
</ul>

1 Answer 1

3

You can simply use:

echo Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
8
  • there are 4 <img src="> in our media.phtml. i replaced in all 4 places in another site. it giving blank page now. i know i did some mistake. please check this code : pasted.co/76a3aae4 and help me what wrong i did ? May 2, 2016 at 12:35
  • @BabyinMagento Just replace $product with $_product in the code I pasted ;) May 2, 2016 at 12:39
  • i don't know how you can post an answer before i post question, thanks a lot :-) May 2, 2016 at 12:46
  • link1 : <?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image')); ?> link2 : <?php echo Mage::getModel('catalog/product_media_config')->getMediaUrl($_product->getImage()); ?> now in link2 image is having more zoom, is there any way to fix it . we using extension May 2, 2016 at 13:01
  • @BabyinMagento what if you do: <?php echo $dexxtz->getImageFeatured(Mage::getModel('catalog/product_media_config')->getMediaUrl($_product->getImage(‌​))); ?> ? May 2, 2016 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.