Magento – Product Image Animated Gif – Reduce image size on Frontend (Magento 1.9.2.4 )

magento-1.9product-images

I was able to get Animated Gif images to show for products by doing this: Though your caching functionality will not work for animated gif image.

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);
}

This works great – except the now animated gifs that appear on the frontend are slightly bigger then the standard .jpg etc…. images that are already up in the product grid (and my recently added products area).

How can I get these to resize to match the appearance of the others?

I have searched and not been able to find an answer. I believe I see earlier on in the code where the image is resized but I am not sure how to get the animated Gif working and have it resize properly to match the other images appearance.

Any help would be appreciated!

Section of a screenshot – Top 6 Images are the Gifs:
ScreenShot

Best Answer

This is how I work with animated gifs.

When you upload an animated gif Magento converts it and re-names.

i.e. if you upload "photo.gif" it will now be "photo_1.gif"

Use an FTP Program to upload the original "photo.gif", but rename it to "photo_1.gif" and overwrite the smaller converted file.

The animated gif should work now. Size should also not be affected.

Related Topic