You are here

function _canvasactions_resizepercent_calculate_percent in ImageCache Actions 7

Same name and namespace in other branches
  1. 8 canvasactions/canvasactions.inc \_canvasactions_resizepercent_calculate_percent()

Calculate percent based on input, fallback if only one value is provided.

Parameters

array $data:

Return value

float[]|FALSE

3 calls to _canvasactions_resizepercent_calculate_percent()
canvasactions_resizepercent_dimensions in canvasactions/canvasactions.inc
Image dimensions callback for the resize percent effect.
canvasactions_resizepercent_effect in canvasactions/canvasactions.inc
Image effect callback for the resize percent effect.
theme_canvasactions_resizepercent_summary in canvasactions/canvasactions.inc
Implements theme_hook() for the resize percent effect summary.

File

canvasactions/canvasactions.inc, line 1026

Code

function _canvasactions_resizepercent_calculate_percent(array $data) {

  // Fallback if only one value is provided.
  if (empty($data['height'])) {
    if (empty($data['width'])) {
      return FALSE;
    }
    $data['height'] = $data['width'];
  }
  else {
    if (empty($data['width'])) {
      $data['width'] = $data['height'];
    }
  }

  // Get percentage values in decimal values.
  $data['width'] = (double) $data['width'] / 100;
  $data['height'] = (double) $data['height'] / 100;
  return $data;
}