array( 'title' => t('Crop any image'), ), 'crop own images' => array( 'title' => t('Crop own images'), ), 'administer imagecrop' => array( 'title' => t('Administer imagecrop settings'), 'description' => t('Administer the basic settings from image javascript crop'), ), ); } /** * Implements hook_theme(). */ function imagecrop_theme() { return array( 'page-imagecrop' => array( 'variables' => array(), 'file' => 'includes/imagecrop.theme.inc', 'function' => 'imagecrop_page', ), 'html-imagecrop' => array( 'variables' => array(), 'template' => 'html-imagecrop', ), 'imagecrop_crop_ui' => array( 'variables' => array( 'style_selection' => array(), 'settings_form' => array(), 'scale_form' => array(), 'imagecrop' => NULL ), 'template' => 'imagecrop-crop-ui', ), 'imagecrop_overview' => array( 'variables' => array( 'style_selection' => array(), 'viewed_style' => NULL, 'edit_url' => NULL, ), 'template' => 'imagecrop-crop-overview', ), ); } /** * Implements hook_menu(). */ function imagecrop_menu() { $items = array(); $items['admin/config/media/imagecrop'] = array( 'title' => 'Image javascript crop', 'page callback' => 'drupal_get_form', 'page arguments' => array('imagecrop_settings_form'), 'access arguments' => array('administer imagecrop'), 'file' => 'includes/imagecrop.admin.inc', ); $items['imagecrop/overview/%'] = array( 'page callback' => 'imagecrop_image_styles_overview', 'page arguments' => array(2), 'type' => MENU_CALLBACK, 'access callback' => 'imagecrop_has_access', 'file' => 'includes/imagecrop.admin.inc', ); $items['imagecrop/crop/%/%'] = array( 'page callback' => 'imagecrop_cropping_page', 'page arguments' => array(2, 3), 'type' => MENU_CALLBACK, 'access callback' => 'imagecrop_has_access', 'file' => 'includes/imagecrop.admin.inc', ); $items['imagecrop/generate_image'] = array( 'page callback' => 'imagecrop_generate_cropready_image', 'access callback' => 'imagecrop_has_access', 'file' => 'includes/imagecrop.admin.inc', ); return $items; } /** * Implements hook_image_effect_info(). */ function imagecrop_image_effect_info() { $effects = array(); $effects['imagecrop_javascript'] = array( 'label' => t('Javascript crop'), 'help' => t('Create a crop with a javascript toolbox.'), 'effect callback' => 'imagecrop_effect', 'form callback' => 'imagecrop_effect_form', 'summary theme' => 'imagecrop_effect_summary', ); return $effects; } /** * Implements hook_imagecrop_popups(). */ function imagecrop_imagecrop_popups() { $popups = array(); if (module_exists('colorbox')) { $popups['imagecrop_colorbox'] = t('Colorbox'); } return $popups; } /** * Implements hook_form_field_ui_field_edit_form_alter(). * Add the imagecrop setting to an imagefield. */ function imagecrop_form_field_ui_field_edit_form_alter(&$form, $form_state) { if ($form['#field']['type'] == 'image') { $styles = get_imagecrop_styles(); if (count($styles) > 0) { $form['instance']['settings']['imagecrop'] = array( '#type' => 'checkboxes', '#options' => $styles, '#title' => t('Available imagecrop styles'), '#description' => t('Select which imagecrop styles should be available for this field'), '#weight' => 12, '#default_value' => isset($form_state['build_info']['args'][0]['settings']['imagecrop']) ? $form_state['build_info']['args'][0]['settings']['imagecrop'] : array(), ); } } } /** * Implements hook_element_info_alter(). */ function imagecrop_element_info_alter(&$type) { $type['managed_file']['#after_build'][] = 'process_imagecrop_form_element'; } /** * Process function for imagecrop-enabled fields. */ function process_imagecrop_form_element($element) { // Leave alone if we are on the field ui settings. if (!isset($element['#field_name'])) { return $element; } // Leave element when user doesn't have access. if (!user_access('crop images with toolbox')) { return $element; } $enabled_styles = imagecrop_get_fields_enabled_styles($element['#entity_type'], $element['#field_name'], $element['#bundle']); // Leave element when no image styles are found for current field. if (count($enabled_styles) == 0) { return $element; } $element['imagecrop'] = array( '#type' => 'markup', '#weight' => 10, '#suffix' => '', ); if ($element['fid']['#value']) { $element['imagecrop']['#prefix'] = '