function image_filter_keyword

Same name in other branches
  1. 9 core/modules/image/image.module \image_filter_keyword()
  2. 8.9.x core/modules/image/image.module \image_filter_keyword()
  3. 10 core/modules/image/image.module \image_filter_keyword()
  4. 11.x core/modules/image/image.module \image_filter_keyword()

Accepts a keyword (center, top, left, etc) and returns it as a pixel offset.

Parameters

$value:

$current_pixels:

$new_pixels:

1 call to image_filter_keyword()
image_crop_effect in modules/image/image.effects.inc
Image effect callback; Crop an image resource.

File

modules/image/image.module, line 1471

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.