I've got pictures of some products in the folder:


But actually not all of them. That size would exactly fit for a site I try to generate (where I'd like to include product pictures).

How can I create images in that size in this folder of all products that I've got in the shop?

How have those been created that are already there?

And how long do the images stay there? Is it safe to link there from a product catalogue?

  • Did you manage to resolve the issue Chris? Commented Mar 31, 2014 at 18:23
  • Yes and no .. I used a workaround with a subtheme and a category. How the images in 168x168 folders are created, I don't know yet but the theme solution is just doing fine for me.
    – Chris
    Commented Apr 1, 2014 at 0:20
  • To close the question please add your workaround as an answer and accept it Commented Apr 1, 2014 at 7:02

2 Answers 2


Whenever you call the catalog/image helper on a product and use the resize method the images are written to a cache path.

echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(168, 168);

This roughly translates to the path you've discribed in your question.


  • media directory
  • catalog directory
  • it's a product
  • it's in the cache
  • 2 is the store ID
  • small image is the type
  • 168x168 are the width and height
  • the hash is an md5 of a sting obtained from concatenating some image settings

Images are kept as long as you don't flush the image cache from the backend. So basically you can upload any size image you like in the backend, the helper will create resized and cached versions of them on the frontend. No need for any manual actions from your end.

  • To add on this...the number (2 in this case) is the store id, and the hash is an md5 of a sting obtained from concatenating some image settings (_keepAspectRatio, _keepFrame, _keepTransparency and others). Check the method Mage_Catalog_Model_Product_Image::setBaseFile almost at the end of it.
    – Marius
    Commented Mar 27, 2014 at 8:06

you can resize images dynamically in magento using class


I've attached a piece of code that I've used for one of my modules

public function resizeImage($width='100',$height='null',$imageUrl){

if($height=='null'):    /*for square images, setting equal height and width*/

$imageName = substr(strrchr($imageUrl,"/"),1);



 $dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imageUrl,'/media'));

    if (!file_exists($imageResized)&&file_exists($dirImg)) :
        $imageObj = new Varien_Image($dirImg);
        $imageObj->resize($width, $height);
return $imageUrl;

public function createdirectory($folder_path){

$dir= new Varien_Io_File;




with your folder names and category ids

your question implies that the images are auto generated, so even if you delete them, they will be generated again.

  • add a comment if you're having issues Commented Mar 27, 2014 at 6:48

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.