Actually I am developing an API in other language and All I am getting using the database but issue lies with the images path. AS resize() function create cached image path and cached image path can differ for every product (mainly due to the hash code folder because its dynamically generated folder at run time). Now for developing API I need to keep generic path but as hash code folder are different I am unable to create generic path for the images. Therefore I need some information so that I can do the changes in my magento code.

1.)I need to know why magento use hash code in image path while resizing the image?

2.) Are we covering any scalability issue or Performance issue by keeping hash code in image cached path?

3.) Can we hard code the hash code in file so every there will be single hash code?

1 Answer 1


I can only answer question 1.
The hash in the image path is generated based on the properties set for the image when the resize is done.
THe image path is constructed in Mage_Catalog_Model_Product_Image::setBaseFile and the hashed part is build like this:

    $miscParams = array(
            ($this->_keepAspectRatio  ? '' : 'non') . 'proportional',
            ($this->_keepFrame        ? '' : 'no')  . 'frame',
            ($this->_keepTransparency ? '' : 'no')  . 'transparency',
            ($this->_constrainOnly ? 'do' : 'not')  . 'constrainonly',
            'angle' . $this->_angle,
            'quality' . $this->_quality

    // if has watermark add watermark params to hash
    if ($this->getWatermarkFile()) {
        $miscParams[] = $this->getWatermarkFile();
        $miscParams[] = $this->getWatermarkImageOpacity();
        $miscParams[] = $this->getWatermarkPosition();
        $miscParams[] = $this->getWatermarkWidth();
        $miscParams[] = $this->getWatermarkHeigth();

    $path[] = md5(implode('_', $miscParams));

this is done so different caches can be created for the same image and the same size but with different options.
For example if you want the same image resized at 200x200 but once with some quality and other time with an other quality, 2 cached images will be created under 2 different folders.

But if you always use the same settings for the parameters listed above, you should always get the same hash.

As a side note, the store id for which you are displaying the resized images is added in the path of the cached image also.

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.