0

I tried creating my own folder for product image size. but in my case by default it is creating "70x" folder. I want my own folder for different image size. I aso want to know that from where magento is creating different product image size folder.

does anyone know how to do this.? Please help me out.

--edit--

i want that particular resize value for e.g."1200x1200" should be saved in my own folder e.g "p1/c:/images/img1.jpg". I m trying my best. but no results.

any solution for this.?

0

The cache folder is generated in the method Mage_Catalog_Model_Product_Image::setBaseFile

   // build new filename (most important params)
    $path = array(
        Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
        'cache',
        Mage::app()->getStore()->getId(),
        $path[] = $this->getDestinationSubdir()
    );
    if((!empty($this->_width)) || (!empty($this->_height)))
        $path[] = "{$this->_width}x{$this->_height}";

    // add misk params as a hash
    $miscParams = array(
            ($this->_keepAspectRatio  ? '' : 'non') . 'proportional',
            ($this->_keepFrame        ? '' : 'no')  . 'frame',
            ($this->_keepTransparency ? '' : 'no')  . 'transparency',
            ($this->_constrainOnly ? 'do' : 'not')  . 'constrainonly',
            $this->_rgbToString($this->_backgroundColor),
            '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));

The $path variable is an array with all the subfolders.

and it looks something like this

array(
    'media/catalog/product', //hardcoded - somehow
    'cache', // - hardcoded
    '1', //the store id
    'image', //the name of the image attribute. can also be `thumbnail`, `small_image` or any other attribute you have
    '70x', //the resize value. if you only call ->resize(70) it will be `70x`. if you call ->resize(70, 90) it will be `70x90`.
    'asjdalsjdlajsdl', //an md5 hash determined by the values of `_keepAspectRatio`, `_keepFrame`, `_keepTransparency`, `_constrainOnly`, `_backgroundColor`, `_angle`, `_quality` and the watermark file an settings.
)

if you want to change this, you have to override the method mentioned above and change the lines I above.

Check also these answers for additional details:

[EDIT]
If you want images resized to 1200x1200 to be in a certain folder, you can modify

if((!empty($this->_width)) || (!empty($this->_height)))
        $path[] = "{$this->_width}x{$this->_height}";

to

if ($this->_width == 1200 && (is_empty($this->_height)) || $this->_height == 1200) {
     $path = 'p1/c:/images';
}
elseif((!empty($this->_width)) || (!empty($this->_height))) {
    $path[] = "{$this->_width}x{$this->_height}";
}
  • Thank u for the reponse..i want that particular resize value for e.g."1200x1200" should be saved in "p1/c:/images/img1.jpg". I m trying my best. but no results. any solution for this.? – Donika Aug 7 '15 at 6:47
  • See my edit. I'm not 100% sure it works, but it's a starting point – Marius Aug 7 '15 at 7:10
  • any other way to try.. – Donika Aug 7 '15 at 7:42
  • Did you try this? I gave you a way...why would you need an other one? – Marius Aug 7 '15 at 8:52
  • yes i tried i am getting some output but not exact what i want – Donika Aug 7 '15 at 9:40

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.