Skip to content
Snippets Groups Projects
Unverified Commit 0eb1d66d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3097797 by jungle, kiamlaluno, dev.patrick, Kristen Pol, ultrabob: Add...

Issue #3097797 by jungle, kiamlaluno, dev.patrick, Kristen Pol, ultrabob: Add the descriptions for parameters and the returned value to image_filter_keyword()
parent 427c7ee7
No related branches found
No related tags found
No related merge requests found
...@@ -297,26 +297,35 @@ function template_preprocess_image_style(&$variables) { ...@@ -297,26 +297,35 @@ function template_preprocess_image_style(&$variables) {
} }
/** /**
* Accepts a keyword (center, top, left, etc) and returns it as a pixel offset. * Returns the offset in pixels from the anchor.
* *
* @param $value * @param string $anchor
* @param $current_pixels * The anchor ('top', 'left', 'bottom', 'right', 'center').
* @param $new_pixels * @param int $current_size
* The current size, in pixels.
* @param int $new_size
* The new size, in pixels.
*
* @return int|string
* The offset from the anchor, in pixels, or the anchor itself, if its value
* isn't one of the accepted values.
*/ */
function image_filter_keyword($value, $current_pixels, $new_pixels) { function image_filter_keyword($anchor, $current_size, $new_size) {
switch ($value) { switch ($anchor) {
case 'top': case 'top':
case 'left': case 'left':
return 0; return 0;
case 'bottom': case 'bottom':
case 'right': case 'right':
return $current_pixels - $new_pixels; return $current_size - $new_size;
case 'center': case 'center':
return $current_pixels / 2 - $new_pixels / 2; return $current_size / 2 - $new_size / 2;
default:
return $anchor;
} }
return $value;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment