From a8420863ca072f519ca3c4e2d4dec77fd3e1723c Mon Sep 17 00:00:00 2001
From: Jeremy Stoller <jstoller@cscmail.org>
Date: Wed, 2 Nov 2016 16:15:39 -0700
Subject: [PATCH] patch

---
 manualcrop.admin.inc | 15 ++++++++++++---
 manualcrop.install   |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/manualcrop.admin.inc b/manualcrop.admin.inc
index f985ca4..f62bae2 100644
--- a/manualcrop.admin.inc
+++ b/manualcrop.admin.inc
@@ -17,6 +17,13 @@ function manualcrop_global_settings_form() {
     '#default_value' => variable_get('manualcrop_cache_control', TRUE),
   );
 
+  $form['manualcrop_force_effect_order'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Force Manual Crop effects to run first'),
+    '#description' => t('Manual Crop effects must execute before the dimentions of the original image are changed. <strong>Disable at your own risk!</strong'),
+    '#default_value' => variable_get('manualcrop_force_effect_order', TRUE),
+  );
+
   $form['#submit'] = array('manualcrop_global_settings_form_submit');
 
   return system_settings_form($form);
@@ -408,7 +415,7 @@ function manualcrop_form_image_effect_form_alter(&$form, &$form_state) {
     // Add the effect info on submit.
     array_unshift($form['#submit'], 'manualcrop_add_effect_info');
   }
-  elseif (!empty($style['effects'])) {
+  elseif (!empty($style['effects']) && variable_get('manualcrop_force_effect_order', TRUE)) {
     // Force the effect order for none-Manual Crop effects.
     $form['#submit'][] = 'manualcrop_force_effect_order';
   }
@@ -470,8 +477,10 @@ function manualcrop_form_image_style_form_alter(&$form, &$form_state) {
       $form['#submit'] = array('image_style_form_submit');
     }
 
-    // Reorder effects on submit.
-    $form['#submit'][] = 'manualcrop_force_effect_order';
+    if (variable_get('manualcrop_force_effect_order', TRUE)) {
+      // Reorder effects on submit.
+      $form['#submit'][] = 'manualcrop_force_effect_order';
+    }
 
     // Update style name in effect data.
     $form['#submit'][] = 'manualcrop_update_style_name';
diff --git a/manualcrop.install b/manualcrop.install
index 20df60c..c16ea16 100644
--- a/manualcrop.install
+++ b/manualcrop.install
@@ -58,6 +58,7 @@ function manualcrop_install() {
  */
 function manualcrop_uninstall() {
   variable_del('manualcrop_cache_control');
+  variable_del('manualcrop_force_effect_order');
 
   if (module_exists('file_entity') && function_exists('file_type_load_all')) {
     // Remove the settings for individual file types.
-- 
2.8.1

