Magento 1.9 Product Images – Change the Path of Product Image

magento-1magento-1.9product-imagesproduct-view

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>

Best Answer

You can simply use:

echo Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
Related Topic