function textactions_keyword_filter in ImageCache Actions 6
Same name and namespace in other branches
- 5.3 textactions.inc \textactions_keyword_filter()
- 5.2 textactions.inc \textactions_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.
Parameters
$value : string or int value. May be something like "20", "center", "left+20"
$current_size: int size in pixels of the range this item is to be placed in
$object_size: int size in pixels of the object to be placed
$xy: Whether the axis is on the x or the y (unused)
1 call to textactions_keyword_filter()
- textactions_text2canvas_image in ./
textactions.inc - Place the source image on the current background
File
- ./
textactions.inc, line 333 - Helper functions for imagecache_textactions
Code
function textactions_keyword_filter($value, $current_pixels, $new_pixels, $adj, $xy) {
// check if we have plus or minus values
$v = explode('+', $value);
$v2 = explode('-', $value);
if (!empty($v2[1])) {
$v[1] = -intval($v2[1]);
$v[0] = $v2[0];
}
switch ($v[0]) {
case 'top':
case 'left':
$value = 0;
break;
case 'bottom':
case 'right':
$value = $current_pixels - $new_pixels;
break;
case 'center':
$value = $current_pixels / 2 - $new_pixels / 2;
break;
}
// Perform the adjustment.
$value = $value + $adj;
// Add any extra negative or positive.
if (!empty($v[1])) {
$value = $value + $v[1];
}
return $value;
}