function image_filter_keyword
Same name and namespace in other branches
- 7.x modules/image/image.module \image_filter_keyword()
- 9 core/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()
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.
Deprecated
in drupal:11.1.0 and is removed from drupal:12.0.0. Use \Drupal\Component\Utility\Image::getKeywordOffset() instead.
See also
https://www.drupal.org/node/3268441
1 call to image_filter_keyword()
- ImageDeprecationTest::testImageFilterKeywordDeprecation in core/
modules/ image/ tests/ src/ Unit/ ImageDeprecationTest.php - Tests deprecation of image_filter_keyword.
File
-
core/
modules/ image/ image.module, line 144
Code
function image_filter_keyword($anchor, $current_size, $new_size) {
@trigger_error('image_filter_keyword() is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use \\Drupal\\Component\\Utility\\Image::getKeywordOffset() instead. See https://www.drupal.org/node/3268441', E_USER_DEPRECATED);
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.