drupal - How to provide a default image file for ImageCache to use and process when the original does not exist? -


Is ImageCancer using a default image to remove it? Or are you using the htaccess to provide a default image to the image cache? The site of some of our clients is> 4 GB and it is very painful from all those images which we do not want for development. I've tried to use htaccess, but does not process on imagecache files and just ends up using the file dimensions which are the layout screws.

Any thoughts?

As I have understood that ImageCache responds like a URI

  http://www.yourdomain.com/default/files/imagecache/ Set / Image / Picture  

Where http://www.yourdomain.com is your domain, files / imagecache is image cache path, Set is the predefined set of image manipulation settings and the remaining (here: images / pic.png ) is the actual relative path of the original image.

Therefore, if pic.png is not present, another file (default page) should be served in the image cache. There may be an .htaccess solution for non-existent files:

  rewrite% {REQUEST_fileNAME}! -f Rewrite rules ^ ([^.] +) \. [Gif | Jpg | Png] $ / images / default.png [L]  

Now the image request image / pic.png which does not exist and becomes images / Default.png prevents, processes and saves it to default / files / imagecache / set / images / pic.png . Okay, at least this is my theory.

Regards, Paul

- ########### -

Edit about the first comment: Ok, In the imagecache.module , the line 386 helper function starts _imagecache_cache ($ presetname, $ path) . Within this function there is a check for the existence of the original file (line 403) Change this block

  // Check that the file path exists or not If (Watch the 'imagecache', '404:% unable to find the image', array ('% image' = ' & Gt; $ Src, WATCHDOG_ERROR); Header ("HTTP / 1.0 404 not found"); Go out; };  

to

  // Check that the file path exists or not. If (Watch the 'imagecache', '404:% unable to find the image', array ('% image' = ' & Gt; $ Src, WATCHDOG_ERROR); / Header ("HTTP / 1.0 404 not found"); Exit; * / $ Src = 'Site / All / Module / Chhakabatch / Sample' '; };  

(Notes: I left the original code line as a comment. You can set $ src to any default file you want.)


Comments