W3cubDocs

/Drupal 8

function image_filter_keyword

image_filter_keyword($value, $current_pixels, $new_pixels)

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

Parameters

$value:

$current_pixels:

$new_pixels:

File

core/modules/image/image.module, line 318
Exposes global functionality for creating image styles.

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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!image!image.module/function/image_filter_keyword/8.1.x