4

Here my code use in our local environment it's working but in live site not working When i click image gif image not open it live site.but in localhost it's working properly

$baseDir = Mage::getBaseDir('media');
  $file = ('gif' == strtolower(pathinfo($this->_baseFile, PATHINFO_EXTENSION))) ? $this->_baseFile : $this->_newFile;
  $path = str_replace($baseDir . DS, "", $file);
  return Mage::getBaseUrl('media') . str_replace(DS, '/', $path);
  • What is the error you are getting in live? Can you check if returns correct url. – Sukumar Gorai Sep 19 '18 at 14:22
  • i have the same problem. Don't get any error message but GIF image is not working on detail page. I have also used same code and it's working fine in localhost but not working in live site. – Sarfaraj Sipai Sep 24 '18 at 8:26
0

Please try with below changes in file :

copy file from

path : app/code/core/Mage/Catalog/Model/Product/Image.php to

path : app/code/local/Mage/Catalog/Model/Product/Image.php (create folders if necessary) Find the line public function getUrl() and replace the function with:

public function getUrl()
    {
        $baseDir = Mage::getBaseDir('media');
        $file = ('gif' == strtolower(pathinfo($this->_baseFile, PATHINFO_EXTENSION))) ? $this->_baseFile : $this->_newFile;
        $path = str_replace($baseDir . DS, "", $file);
        return Mage::getBaseUrl('media') . str_replace(DS, '/', $path);
    }

hope this will help you.

  • this is magneto1 i am using magneto2 – Rv Singh Aug 30 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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