I performed a complete cache clean and discovered that this obliterates everything under /media/ (as noted by me below and later correctly observed by an answer, it is indeed just the cache that is being wiped under the /media/ folder). Unfortunately there are some email distributions from the past that rely on these images and I am curious as to whether there is a way to regenerate all of the thumbnails / cache entries under the /media/ folder?

So, for example, in this situation I am seeing missing files such as:

[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/T/E/TE0213.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/X/FX0413_1.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/B/FB0413.jpg
[Mon Apr 15 11:46:01 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/K/FK0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/E/V/EV0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/P/FP0413.jpg
[Mon Apr 15 11:46:02 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/E/FEA0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/Z/FZ0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/G/B/GB0413.jpg
[Mon Apr 15 11:46:03 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/S/FS0413.jpg
[Mon Apr 15 11:46:04 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/0/image/265x/4df79eab33525d08d6e5fb8d27136e95/F/U/FU0413.jpg

When I do look for the images, for example, I do see the originals present in: media/catalog/product/F/U/

The goal, therefore, is to regenerate all of these appropriately.

Moving further along in this, I can see that I need to be able to execute a Magento script upon failure of finding an image (particularly since many of these images are not being found due to being called by external references such as emails or other sites). I expect to use something like this from Apache to call this script that I'm hoping to get help on here:

# Inside of .htaccess:
# if the file exists, just send it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^cache/.*$ - [L]

# if it doesn't exists, rewrite to PHP script
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^cache/.*$ /path/to/script.php?url=$0 [L]
  • There is no way to regenerate them - except to do it manually. afaik. Commented Apr 15, 2013 at 16:36

3 Answers 3


File does not exist: /home/username/public_html/domain.tld/media/catalog/product/cache/

It cleared the image cache.


Your original images are still in place, so the clear image cache function obviously did not do as you first said, obliterates everything under /media/

Your major problem then is that your templates are not doing proper media helper calls to regenerate the image. Where exactly are you having your missing image problem?

A typical helper call asks for the url, if no URL exists, the image is added to the cache on the fly with the size chosen and then the URL is returned to the html block.

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

Product View Page image

<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />

Product Listing

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />

Note that the init function for the helper takes the following inputs:

public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)

and processes $imageFile with the following:

if ($imageFile) {
} else {
    // add for work original size

POC code that feeds out resized image url when queried with image string. For Store 1 in this sample, yours according to the given URLs is Store 0.


 * imgurl.php allows you to return image url for imgquery.
 * http://www.example.com/imgurl.php?imgurl=/l/p/lp_5009.jpg


require_once 'app/Mage.php';
$userModel = Mage::getModel('admin/user');

$product  = "0";
$imgurl   = "";

if (isset($_GET["imgquery"])) {  

    $string = filter_input(INPUT_GET, 'imgquery', FILTER_SANITIZE_URL);

    $imgquery = trim($string);

    $imgurl = Mage::helper('catalog/image')->init($product, 'image', $imgquery)->resize(250, 250);


if ($imgurl) {

    echo '<img src="' . $imgurl . '"/>';


Feed it a get query:


Which kicks out:

<img src="http://www.example.com/media/catalog/product/cache/1/image/250x250/9df78eab33525d08d6e5fb8d27136e95/l/p/lp_5009.jpg"/>
  • 1
    Thanks for correcting my wording above. The missing images are particularly present from old emails that included images from a week and more ago. Customers have been calling in and asking why they can no longer see images. I have to, in some fashion, be able to regenerate these caches upon any inquiry. As such, I am expecting that I should probably somehow create a task for cron (and manual calling) that will go through the images and regenerate the smaller versions in cache...
    – ylluminate
    Commented Apr 15, 2013 at 19:43
  • This is the biggest issue with email designers and Magneto - you can't link directly to the frontend image because it's a cache that's generated with a hash. We had to learn the hard way with this. @sonassi has a great blog post on how this is constructed: sonassi.com/knowledge-base/…
    – philwinkle
    Commented Apr 15, 2013 at 19:56
  • As you'll notice above, I've added a little more detail of what I plan on doing to call it via .htaccess.
    – ylluminate
    Commented Apr 15, 2013 at 20:34
  • The helper method requires knowing the product to build its cached image, the reverse of what we're trying to do then which is to take the cached image url and have it call a function that resizes and caches the original. Commented Apr 15, 2013 at 23:32
  • @FiascoLabs would you be able to give an example script of the scenario I outlined where we have /home/username/public_html/domain.tld/media/catalog/product/cache/1/small_image/220x220/4da38bab36523d0886e53b8d57126395/R/A/RA01112.jpg and need to run that via a php script from .htaccess? I simply need to see some kind of a precise example as Magento is quite new to me and I'm concerned about how this all ties together in a comprehensive script that I can call properly.
    – ylluminate
    Commented Apr 16, 2013 at 0:01

This error in my case with magento is a bad code of zoom image module.

Disable it to get the work.
  • Yes the Magentothem ProZoom also giving me issues
    – tread
    Commented Nov 27, 2014 at 9:04

The files are generated, when needed. You need a call to Mage::helper('catalog/image)->... to create these images. You can do it either manually or you might write a script to redirect all requests to /media/ to this script do generate the images just in time

  • Thanks for that! Can you post a sample php script that I could insert into the home folder to initiate a regen of all images? I discovered a problem with permissions and have set the owner to also be part of the nobody group that apache has started using for some unknown reason and so that has been similarly causing problems. Ultimately I need to evoke some method to force a regeneration of all missing cache assets.
    – ylluminate
    Commented Apr 15, 2013 at 18:00
  • As you may note above, I've added some more detail of the missing files so essentially I need to regen all files under the common folder structure.
    – ylluminate
    Commented Apr 15, 2013 at 18:13

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.