You are here

function _media_crop_effects_are_compatible in Media crop 7

Checks if a list of effects are compatible with the cropping interface.

Parameters

array $effects: List of image effects.

Return value

bool Compatible or not.

3 calls to _media_crop_effects_are_compatible()
media_crop_form_image_style_form_alter in ./media_crop.module
Implements hook_form_FORM_ID_alter().
media_crop_media_format_form_prepare_alter in ./media_crop.module
Implements hook_media_format_form_prepare_alter().
_media_crop_apply_image_style in ./media_crop.module
Helper function to apply image style to an image.

File

./media_crop.module, line 906
Media crop primary module file.

Code

function _media_crop_effects_are_compatible($effects) {
  static $safe_rotations = array(
    0,
    90,
    180,
    270,
  );
  $crop = FALSE;
  $rotate = FALSE;
  foreach ($effects as $effect) {
    switch ($effect['name']) {
      case 'image_rotate':
        if ($crop || $rotate || !in_array($effect['data']['degrees'], $safe_rotations)) {
          return FALSE;
        }
        $rotate = TRUE;
        break;
      case 'image_crop':
        if ($crop) {
          return FALSE;
        }
        $crop = TRUE;
        break;
      default:
        if (_media_crop_is_effect_changes_dimension($effect)) {
          return FALSE;
        }
    }
  }
  return TRUE;
}