You are here

function _imagecache_keyword_filter in ImageCache 6.2

Same name and namespace in other branches
  1. 5.2 imagecache.module \_imagecache_keyword_filter()
  2. 5 imagecache.module \_imagecache_keyword_filter()

Accept a keyword (center, top, left, etc) and return it as an offset in pixels.

1 call to _imagecache_keyword_filter()
imagecache_build_derivative in ./imagecache.module
Create a new image based on an image preset.

File

./imagecache.module, line 816
Dynamic image resizer and image cacher.

Code

function _imagecache_keyword_filter($value, $current_pixels, $new_pixels) {
  switch ($value) {
    case 'top':
    case 'left':
      $value = 0;
      break;
    case 'bottom':
    case 'right':
      $value = $current_pixels - $new_pixels;
      break;
    case 'center':
      $value = $current_pixels / 2 - $new_pixels / 2;
      break;
  }
  return $value;
}