I would like to add a custom folder when magento creates the path for a product image. If image name is image.jpg the path will be ../media/catalog/product/i/m/image.jpg. What I need is ../media/catalog/product/i/m/CUSTOM_FOLDER/image.jpg.

Basically I need to find the .php that create this image path when the product is created and edit it.


  • I don't really understand the aim behind the type of URL but if you can clear some more, then may be we can help you in different way? Oct 27, 2015 at 4:47

1 Answer 1


I think everything happens in Mage_Catalog_Model_Product_Attribute_Backend_Media::addImage.

Look for the line

$fileName       = $dispretionPath . DS . $fileName; 

where dispretionPath is /i/m and $fileName is image.jpg in the example you gave. Try to insert something betweeen them.

You may also need to modify some code below that line.

  • I'll try and give you a feedback. Jul 9, 2014 at 13:15
  • It didn't work. Have you tried it yourself? Anyways, I needed this because my images are been overriding when they have the same name. However it was not by Magento's fault but MAGMI image processor. Jul 9, 2014 at 14:23
  • I haven't tried this. I just poked a bit in the code to see where the file is uploaded. But I have a feeling that Magmi does it differently, so even if you change the way the image path is stored you will probably still get issues.
    – Marius
    Jul 9, 2014 at 14:26
  • Yes, you're correct. I'm already talking with dweeves, MAGMI developer. By the way, I tried your awnser with MAGMI and also directly in Magento. Jul 9, 2014 at 14:27
  • I will dig deeper when I will find some time and maybe I will come up with a better answer.
    – Marius
    Jul 9, 2014 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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