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
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -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 $current_pixels
 * @param $new_pixels
 * @param string $anchor
 *   The anchor ('top', 'left', 'bottom', 'right', 'center').
 * @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) {
  switch ($value) {
function image_filter_keyword($anchor, $current_size, $new_size) {
  switch ($anchor) {
    case 'top':
    case 'left':
      return 0;

    case 'bottom':
    case 'right':
      return $current_pixels - $new_pixels;
      return $current_size - $new_size;

    case 'center':
      return $current_pixels / 2 - $new_pixels / 2;
      return $current_size / 2 - $new_size / 2;

    default:
      return $anchor;
  }
  return $value;
}

/**