Skip to content

Instantly share code, notes, and snippets.

@thewilkybarkid
Created August 27, 2013 09:08
Show Gist options
  • Save thewilkybarkid/6351355 to your computer and use it in GitHub Desktop.
Save thewilkybarkid/6351355 to your computer and use it in GitHub Desktop.
Patch for the Drupal Image javascript crop module (version 7.x-1.0-rc3) that forces the module to use the admin theme rather than the normal one (see https://drupal.org/node/1491494).
diff --git a/imagecrop.module b/imagecrop.module
index f3e2f72..40bf3f1 100644
--- a/imagecrop.module
+++ b/imagecrop.module
@@ -31,6 +31,10 @@ function imagecrop_permission() {
);
}
+function imagecrop_get_theme() {
+ return variable_get('admin_theme');
+}
+
/**
* Implements hook_theme().
*/
@@ -104,6 +108,7 @@ function imagecrop_menu() {
'page arguments' => array(2, 3),
'type' => MENU_CALLBACK,
'access callback' => 'imagecrop_has_access',
+ 'theme callback' => 'imagecrop_get_theme',
'file' => 'includes/imagecrop.admin.inc',
'title' => 'Imagecrop overview',
);
@@ -113,6 +118,7 @@ function imagecrop_menu() {
'page arguments' => array(2, 3, 4),
'type' => MENU_CALLBACK,
'access callback' => 'imagecrop_has_access',
+ 'theme callback' => 'imagecrop_get_theme',
'file' => 'includes/imagecrop.admin.inc',
);
diff --git a/includes/imagecrop.theme.inc b/includes/imagecrop.theme.inc
index c318ab0..c9749a0 100644
--- a/includes/imagecrop.theme.inc
+++ b/includes/imagecrop.theme.inc
@@ -17,7 +17,7 @@ function imagecrop_page($variables) {
$output .= $variables['messages'];
}
- global $theme;
+ $theme = imagecrop_get_theme();
$query = db_select('block');
$query->addField('block', 'region');
$query->condition('theme', $theme);
@@ -25,7 +25,6 @@ function imagecrop_page($variables) {
$query->condition('delta', 'main');
$region = $query->execute()->fetchField();
- global $theme;
if (isset($variables['page'][$region])) {
$output .= drupal_render($variables['page'][$region]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment