You are here

function _manualcrop_image_style_label in Manual Crop 7

Transform a style name into a more readable variant.

Parameters

$style: Image style info array or style name.

Return value

Cleaned-up image style name.

5 calls to _manualcrop_image_style_label()
manualcrop_croptool_validate in ./manualcrop.module
Element validation handler; Validates each crop selection.
manualcrop_styles_with_crop in ./manualcrop.helpers.inc
Returns the styles that have crop settings.
theme_manualcrop_auto_reuse_summary in ./manualcrop.admin.inc
Returns HTML for a summary of an image crop selection auto reuse effect.
theme_manualcrop_crop_summary in ./manualcrop.admin.inc
Returns HTML for a summary of an image crop effect.
theme_manualcrop_reuse_summary in ./manualcrop.admin.inc
Returns HTML for a summary of an image crop selection reuse effect.
1 string reference to '_manualcrop_image_style_label'
manualcrop_auto_reuse_form in ./manualcrop.admin.inc
Form Builder; Configuration settings for the auto reuse effect.

File

./manualcrop.helpers.inc, line 755
Helper functions for the Manual Crop module.

Code

function _manualcrop_image_style_label($style) {
  global $language;
  static $custom_strings;

  // Get the image style info.
  if (!is_array($style)) {
    $styles = image_styles();
    if (isset($styles[$style])) {
      $style = $styles[$style];
    }
    else {

      // Normally we shouldn't be here...
      $style = array(
        'name' => $style,
      );
    }
  }

  // The label is only available in Drupal 7.23 and up.
  if (isset($style['label'])) {
    return $style['label'];
  }
  else {
    $style_name = $style['name'];
    $langcode = isset($language->language) ? $language->language : 'en';

    // Load custom string for overriding.
    if (!isset($custom_strings[$langcode])) {
      $custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
    }

    // Get the human readable name from the custom strings or make it ourself.
    if (isset($custom_strings[$langcode]['']['image-style-' . $style_name])) {
      return $custom_strings[$langcode]['']['image-style-' . $style_name];
    }
    else {
      return ucwords(str_replace('_', ' ', $style_name));
    }
  }
}