You are here

function manualcrop_styles_with_crop in Manual Crop 7

Returns the styles that have crop settings.

Parameters

$include_reuse: Set to TRUE to include styles with a Manual Crop reuse effect.

$exclude_arg: Exclude the style that is set as a menu argument on this index.

$return_label: Set to TRUE to return the label instead of an array.

Return value

If $label is set to TRUE, this function will return an array of style labels keyed by style name. Otherwise an array of crop-enabled styles will be returned. This array is also keyed by style name and each element in this array is also an array with 2 elements:

  • "label": Human readable style label.
  • "effect": Manual Crop effect data.
11 calls to manualcrop_styles_with_crop()
manualcrop_auto_reuse_form in ./manualcrop.admin.inc
Form Builder; Configuration settings for the auto reuse effect.
manualcrop_croptool_process in ./manualcrop.helpers.inc
Add a croptool to the form element. This extends the FAPI widget or simply adds a new form item to enable cropping in a regular form.
manualcrop_crop_form in ./manualcrop.admin.inc
Form builder; Configuration settings for crop effect.
manualcrop_field_widget_info_alter in ./manualcrop.module
Implements hook_field_widget_info_alter().
manualcrop_field_widget_settings_form in ./manualcrop.admin.inc
Add the Manual Crop field widget settings.

... See full list

File

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

Code

function manualcrop_styles_with_crop($include_reuse = FALSE, $exclude_arg = NULL, $return_label = FALSE) {
  $hascrop =& drupal_static(__FUNCTION__);
  if (!is_array($hascrop)) {
    $hascrop = array(
      array(),
      array(),
    );
    foreach (image_styles() as $style_name => $style) {
      if (!empty($style['effects'])) {

        // Check if the first effect is a Manual Crop cropping effect.
        $effect = reset($style['effects']);
        if (_manualcrop_is_own_effect($effect)) {
          $label = _manualcrop_image_style_label($style);
          $hascrop[1][$style_name] = array(
            'label' => $label,
            'effect' => $effect,
          );
          if (_manualcrop_is_own_effect($effect, TRUE)) {
            $hascrop[0][$style_name] = array(
              'label' => $label,
              'effect' => $effect,
            );
          }
        }
      }
    }
  }

  // With or without reuse effects.
  $styles = $hascrop[(int) $include_reuse];

  // Exclude a style by menu arument.
  if (!is_null($exclude_arg)) {
    $exclude_arg = arg($exclude_arg);
    if (isset($styles[$exclude_arg])) {
      unset($styles[$exclude_arg]);
    }
  }

  // Only the labels should be returned.
  if ($return_label) {
    foreach ($styles as $style_name => $style) {
      $styles[$style_name] = $style['label'];
    }
  }
  return $styles;
}