You are here

function variable_file_format_image in Variable Extra 7

Variable format callback. Image.

1 string reference to 'variable_file_format_image'
variable_file_variable_type_info in variable_file/variable_file.variable.inc
Implements hook_variable_type_info().

File

variable_file/variable_file.variable.inc, line 259
Variable module hook implementations

Code

function variable_file_format_image($variable, $options = array()) {
  if ($path = _variable_file_get_path($variable)) {
    $style_name = $variable['image style'];
    $style_path = image_style_path($style_name, $path);

    // Check the image style is created, create if not.
    if (!file_exists($style_path)) {
      $style_path = image_style_url($style_name, $path);
    }
    $variables = image_get_info($style_path);
    $variables['path'] = $style_path;
    return theme('image', $variables);
  }
  else {
    return t('No image');
  }
}