function image_filter_keyword
Same name in other branches
- 7.x modules/image/image.module \image_filter_keyword()
- 8.9.x core/modules/image/image.module \image_filter_keyword()
- 10 core/modules/image/image.module \image_filter_keyword()
- 11.x core/modules/image/image.module \image_filter_keyword()
Returns the offset in pixels from the anchor.
Parameters
string $anchor: The anchor ('top', 'left', 'bottom', 'right', 'center').
int $current_size: The current size, in pixels.
int $new_size: The new size, in pixels.
Return value
int|string The offset from the anchor, in pixels, or the anchor itself, if its value isn't one of the accepted values.
2 calls to image_filter_keyword()
- CropImageEffect::applyEffect in core/
modules/ image/ src/ Plugin/ ImageEffect/ CropImageEffect.php - Applies an image effect to the image object.
- ScaleAndCropImageEffect::applyEffect in core/
modules/ image/ src/ Plugin/ ImageEffect/ ScaleAndCropImageEffect.php - Applies an image effect to the image object.
File
-
core/
modules/ image/ image.module, line 315
Code
function image_filter_keyword($anchor, $current_size, $new_size) {
switch ($anchor) {
case 'top':
case 'left':
return 0;
case 'bottom':
case 'right':
return $current_size - $new_size;
case 'center':
return $current_size / 2 - $new_size / 2;
default:
return $anchor;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.