diff --git a/sites/all/modules/contrib/imagefield_crop/imagefield_crop.module b/sites/all/modules/contrib/imagefield_crop/imagefield_crop.module index 6fb6c3b..f64093e 100644 --- a/sites/all/modules/contrib/imagefield_crop/imagefield_crop.module +++ b/sites/all/modules/contrib/imagefield_crop/imagefield_crop.module @@ -261,7 +261,7 @@ function imagefield_crop_field_widget_info() { 'field types' => array('imagefield_crop'), 'settings' => array( 'progress_indicator' => 'throbber', - 'preview_image_style' => 'thumbnail', + 'preview_image_width' => 'thumbnail', 'collapsible' => 2, 'resolution' => '200x150', 'validate_resolution' => 0, @@ -430,6 +430,22 @@ function imagefield_crop_field_widget_settings_form($field, $instance) { ), '#default_value' => $settings['gif_processing'], ); + + /* Introduce different setting for preview box. + * Width of the box should be defined, rather than image style, + * as its proportions are already defined by "resolution" of the cropping. + */ + unset($form['preview_image_style']); + $form['preview_image_width'] = array( + '#title' => t('Preview box width'), + '#type' => 'textfield', + '#default_value' => $settings['preview_image_width'], + '#size' => 5, + '#maxlength' => 5, + '#field_suffix' => ' ' . t('pixels'), + '#weight' => 15, + '#description' => t('Scale cropped image to a given width for preview.'), + ); return $form; } @@ -642,6 +658,11 @@ function imagefield_crop_widget_preview_process($element, &$form_state, $form) { $parent = drupal_array_get_nested_value($form, $parents); $instance = field_widget_instance($parent, $form_state); list($width, $height) = !empty($instance['widget']['settings']['resolution']) ? explode('x', $instance['widget']['settings']['resolution']) : array(0, 0); + + if (!empty($instance['widget']['settings']['preview_image_width'])) { + $height = $instance['widget']['settings']['preview_image_width'] / $width * $height; + $width = $instance['widget']['settings']['preview_image_width']; + } $image_info = image_get_info(drupal_realpath($file->uri)); $settings = array(