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

Is it possible to get ImageCache to use the default image? Or using htaccess to provide the default image for imagecache processing? Some of our client sites are> 4 GB, and this is very painful for all of their images that we do not need for development. I tried using htaccess, but ImageCache does not process the file and just ends up using file sizes that twist the layout.

Any thoughts?

+3
source share
2 answers

As I understand it, ImageCache responds to a URI, for example

http://www.yourdomain.com/default/files/imagecache/set/images/pic.png

http://www.yourdomain.com - , files/imagecache - imagecache, set - , (: images/pic.png) - .

, pic.png , (default.png) ImageCache. .htaccess :

RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule ^([^.]+)\.[gif|jpg|png]$ /images/default.png [L]

ImageCache images/pic.png, images/default.png, default/files/imagecache/set/images/pic.png.

, , .

,

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

EDIT : , . imagecache.module 386 _imagecache_cache($presetname, $path). ( 403).

  // Check if the path to the file exists.
  if (!is_file($src) && !is_file($src = file_create_path($src))) {
    watchdog('imagecache', '404: Unable to find %image ', array('%image' => $src), WATCHDOG_ERROR);
    header("HTTP/1.0 404 Not Found");
    exit;
  };

  // Check if the path to the file exists.
  if (!is_file($src) && !is_file($src = file_create_path($src))) {
    watchdog('imagecache', '404: Unable to find %image ', array('%image' => $src), WATCHDOG_ERROR);
    /*header("HTTP/1.0 404 Not Found");
    exit;*/
    $src = 'sites/all/modules/imagecache/sample.png';
  };

(: . $src , .)

+2

, , , 1-10 + .

, ( "imagecache" ) ( "image_style" ) . , .

http://drupal.org/project/imagecache_defaults

Drupal 6 7.

(http://drupal.org/ node/908282), imagecache_defaults , , ( -db).

0

Source: https://habr.com/ru/post/1750746/


All Articles