2

I have a custom module in which i want to change folder structure...how to change default folder structure for image upload..i want to upload and fetch images from newly created folder for e.g "r->small_img->img1.jpg"....whenever i try to fetch or upload images it creates "catalog->product" folder. Is it possible to change the default folder structure.??? I want my product images to store in other newly created folder and fetch from it??? Is this possible????........

Please help me out

--edit--

I want my images to be uploaded from another server and fetch from there only and whenever i m trying to do that it automatically creates "catalog->product" folder and do fetching and uploading process from it......I want that it should fetch from newly created folder and upload to it only... any solution for this –

Donika
  • 547
  • 8
  • 19

2 Answers2

4

The default path is determined in Mage_Catalog_Model_Product_Media_Config::getBaseMediaPath().
By default it looks like this:

public function getBaseMediaPath()
{
    return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product';
}

Rewrite the class and change it to what ever you need.
But you will also have to change the mehtod getBaseMediaUrlAddition.
By default it looks like this:

public function getBaseMediaUrlAddition()
{
    return 'catalog/product';
}

Change it accordingly to the previous method.
To the same for getBaseMediaUrl

And to change the cache path you need to rewrite the method Mage_Catalog_Model_Product_Image::setBaseFile.
The cached image path is generated starting with these lines

    $path = array(
        Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath(),
        'cache',
        Mage::app()->getStore()->getId(),
        $path[] = $this->getDestinationSubdir()
    );
Marius
  • 197,939
  • 53
  • 422
  • 830
1

What have you tried? Sure it is possible, but afaik the pathes are hardcoded at various places, so it is a lot of work. Why do you want do it?

Beside this maybe a start of an answer:

Change only the Mage_Catalog_Helper_Image to return another path and then fix the path with .htaccess or better Vhost config rewrite

Fabian Blechschmidt
  • 35,388
  • 8
  • 75
  • 182