From ec821b01a6efee6ab23c53355cee8c84c51afc0d Mon Sep 17 00:00:00 2001 From: thewilkybarkid <chriswilkinson84@gmail.com> Date: Fri, 9 Aug 2013 11:28:07 +0100 Subject: [PATCH] Replacing automatic cropping with the Image javascript crop module --- cambridge.info | 1 + cambridge.install | 86 +++++++++++++++++++++++++++++++++++++++++++++++ cambridge.make | 1 + 3 files changed, 88 insertions(+) diff --git a/cambridge.info b/cambridge.info index a998c83..58788ae 100644 --- a/cambridge.info +++ b/cambridge.info @@ -34,6 +34,7 @@ dependencies[] = admin_menu dependencies[] = admin_menu_toolbar dependencies[] = advanced_help dependencies[] = date +dependencies[] = imagecrop dependencies[] = link dependencies[] = pathauto dependencies[] = php diff --git a/cambridge.install b/cambridge.install index 2473ef7..19caed3 100644 --- a/cambridge.install +++ b/cambridge.install @@ -16,4 +16,90 @@ function cambridge_install() { require_once 'cambridge_lite.install'; cambridge_lite_install(); + + // Set some sensible defaults for the Image javascript crop module. + + variable_set('imagecrop_popup', 'imagecrop_iframe'); + variable_set('imagecrop_scale_default', 1); + variable_set('imagecrop_show_cancel_button', 1); + variable_set('imagecrop_ui_controls', 1); + + // Replace standard scaling/cropping image style effects and replace them with a Javascript crop effect. + + $carousel = image_style_load('carousel'); + foreach ($carousel['effects'] as $effect) { + image_effect_delete($effect); + } + + image_effect_save( + array( + 'name' => 'imagecrop_javascript', + 'data' => array( + 'width' => 885, + 'height' => 432, + 'xoffset' => 'center', + 'yoffset' => 'center', + 'resizable' => 0, + 'downscaling' => 0, + 'aspect_ratio' => 'CROP', + 'disable_if_no_data' => 0, + ), + 'isid' => $carousel['isid'], + 'weight' => 0, + ) + ); + + $instance = field_info_instance('node', 'field_carousel_image', 'carousel_item'); + $instance['settings']['imagecrop'] = array('carousel' => 'carousel', 'leading' => 0, 'inline' => 0); + field_update_instance($instance); + + $leading = image_style_load('leading'); + foreach ($leading['effects'] as $effect) { + image_effect_delete($effect); + } + + image_effect_save( + array( + 'name' => 'imagecrop_javascript', + 'data' => array( + 'width' => 590, + 'height' => 288, + 'xoffset' => 'center', + 'yoffset' => 'center', + 'resizable' => 0, + 'downscaling' => 0, + 'aspect_ratio' => 'CROP', + 'disable_if_no_data' => 0, + ), + 'isid' => $leading['isid'], + 'weight' => 0, + ) + ); + + $instance = field_info_instance('node', 'field_leading_image', 'page'); + $instance['settings']['imagecrop'] = array('leading' => 'leading', 'carousel' => 0, 'inline' => 0); + field_update_instance($instance); + + $inline = image_style_load('inline'); + foreach ($inline['effects'] as $effect) { + image_effect_delete($effect); + } + + image_effect_save( + array( + 'name' => 'imagecrop_javascript', + 'data' => array( + 'width' => 250, + 'height' => 250, + 'xoffset' => 'center', + 'yoffset' => 'center', + 'resizable' => 0, + 'downscaling' => 0, + 'aspect_ratio' => 'CROP', + 'disable_if_no_data' => 0, + ), + 'isid' => $inline['isid'], + 'weight' => 0, + ) + ); } diff --git a/cambridge.make b/cambridge.make index 896757e..5a809f4 100644 --- a/cambridge.make +++ b/cambridge.make @@ -11,3 +11,4 @@ projects[context] = "3.0-beta7" projects[date] = "2.6" projects[easy_breadcrumb] = "2.7" projects[google_analytics] = "1.3" +projects[imagecrop] = "1.0-rc3" -- GitLab