function imagecache_actions_keyword_filter in ImageCache Actions 8
Same name and namespace in other branches
- 6.2 utility.inc \imagecache_actions_keyword_filter()
- 6 utility.inc \imagecache_actions_keyword_filter()
- 7 utility.inc \imagecache_actions_keyword_filter()
Accept a keyword (center, top, left, etc) and return it as an offset in pixels. Called on either the x or y values.
May be something like "20", "center", "left+20", "bottom+10". + values are in from the sides, so bottom+10 is 10 UP from the bottom.
"center+50" is also OK.
"30%" will place the CENTER of the object at 30% across. to get a 30% margin, use "left+30%"
Parameters
string|int $value: string or int value.
int $base_size: Size in pixels of the range this item is to be placed in.
int $layer_size: Size in pixels of the object to be placed.
Return value
int
2 calls to imagecache_actions_keyword_filter()
- imagecache_testsuite_positioning in tests/
imagecache_testsuite.module - Display a page demonstrating a number of positioning tests
- image_overlay in ./
image_overlay.inc - Places one image over another.
1 string reference to 'imagecache_actions_keyword_filter'
- canvasactions.inc in canvasactions/
canvasactions.inc
File
- ./
utility.inc, line 457 - utility.inc: uitility form, conversion and rendering functions for image processing.
Code
function imagecache_actions_keyword_filter($value, $base_size, $layer_size) {
// See above for the patterns this matches.
if (!preg_match('/([a-z]*) *([+-]?) *(\\d*)((px|%)?)/', $value, $results)) {
trigger_error("imagecache_actions had difficulty parsing the string '{$value}' when calculating position. Please check the syntax.", E_USER_WARNING);
}
list(, $keyword, $plusminus, $value, $unit) = $results;
return imagecache_actions_calculate_offset($keyword, $plusminus . $value . $unit, $base_size, $layer_size);
}