diff options
Diffstat (limited to 'modules/image/image.module')
-rw-r--r-- | modules/image/image.module | 174 |
1 files changed, 155 insertions, 19 deletions
diff --git a/modules/image/image.module b/modules/image/image.module index a6803a667..35c44e219 100644 --- a/modules/image/image.module +++ b/modules/image/image.module @@ -7,6 +7,33 @@ */ /** + * Implement of hook_help(). + */ +function image_help($path, $arg) { + switch ($path) { + case 'admin/help#image': + $naming_approaches = array(); + $naming_approaches[] = t('Based on where it will be used: !name', array('!name' => '<code>profile-picture</code>')); + $naming_approaches[] = t('Describing its appearance: !name', array('!name' => '<code>square-85x85</code>')); + $output = ''; + $output .= '<p>' . t('The Image module provides functionality for displaying images on your site though <a href="!url">image styles</a>.', array('!url' => url('admin/settings/image-styles'))) .'</p>'; + $output .= '<h3>' . t('Image styles') . '</h3>'; + $output .= '<p>' . t('Image <em>styles</em> allow your site to output an image in several different ways without affecting the original image. Any created images will automatically be refreshed if any changes are made to the image style.') .'</p>'; + $output .= '<p>' . t('Every image style must have a name, which will be used in the URL of generated images. There are two common approaches to naming image styles:') . '</p>'; + $output .= theme('item_list', $naming_approaches); + $output .= '<p>' . t('Both approaches are common and which you choose depends on how you use the image style.') . '</p>'; + $output .= '<p>' . t('After creating an image style, <em>effects</em> may be added to the style. Image module comes with some basic effects such as <em>crop</em>, <em>scale</em>, <em>desaturate</em>, and <em>rotate</em>. In addition to the effects included with Image, other modules may provide additional effects. Multiple effects may be combined together, such as using the <em>crop and scale</em> effect and the <em>desaturate</em> effect, you could create square, grayscale thumbnails.'); + return $output; + case 'admin/settings/image-styles': + return '<p>' . t('Image styles commonly provide thumbnail sizes by scaling and cropping images, but can also add various effects before an image is displayed. When an image is displayed with a style, a new file is created and the original image is left unchanged.') . '</p>'; + case 'admin/settings/image-styles/edit/%/add/%': + case 'admin/settings/image-styles/edit/%/effects/%': + $effect = ($arg[5] == 'add') ? image_effect_definition_load($arg[6]) : image_effect_load($arg[6]); + return isset($effect['help']) ? ('<p>' . $effect['help'] . '</p>') : NULL; + } +} + +/** * Implement hook_menu(). */ function image_menu() { @@ -19,6 +46,79 @@ function image_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); + $items['admin/settings/image-styles'] = array( + 'title' => 'Image styles', + 'description' => 'Configure styles that can be used for resizing or adjusting images on display.', + 'page callback' => 'image_style_list', + 'access arguments' => array('administer image styles'), + ); + $items['admin/settings/image-styles/list'] = array( + 'title' => 'List', + 'description' => 'List the current image styles on the site.', + 'page callback' => 'image_style_list', + 'access arguments' => array('administer image styles'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => 1, + ); + $items['admin/settings/image-styles/add'] = array( + 'title' => 'Add style', + 'description' => 'Add a new image style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_style_add_form'), + 'access arguments' => array('administer image styles'), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2, + ); + $items['admin/settings/image-styles/edit/%image_style'] = array( + 'title' => 'Edit style', + 'title callback' => 'image_style_title', + 'title arguments' => array('!name', 4), + 'description' => 'Configure an image style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_style_form', 4), + 'access arguments' => array('administer image styles'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/image-styles/delete/%image_style'] = array( + 'title' => 'Delete style', + 'title callback' => 'image_style_title', + 'title arguments' => array('Delete !name', 4), + 'description' => 'Delete an image style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_style_delete_form', 4, TRUE), + 'access arguments' => array('administer image styles'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/image-styles/edit/%image_style/effects/%image_effect'] = array( + 'title' => 'Edit image effect', + 'title callback' => 'image_effect_title', + 'title arguments' => array('!label effect', 6), + 'description' => 'Edit an exiting effect within a style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_effect_form', 4, 6), + 'access arguments' => array('administer image styles'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/image-styles/edit/%image_style/effects/%image_effect/delete'] = array( + 'title' => 'Delete image effect', + 'title callback' => 'image_effect_title', + 'title arguments' => array('Delete !label', 6), + 'description' => 'Delete an exiting effect from a style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_effect_delete_form', 4, 6), + 'access arguments' => array('administer image styles'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/image-styles/edit/%image_style/add/%image_effect_definition'] = array( + 'title' => 'Add image effect', + 'title callback' => 'image_effect_title', + 'title arguments' => array('Add !label effect', 6), + 'description' => 'Add a new effect to a style.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('image_effect_form', 4, 6), + 'access arguments' => array('administer image styles'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -38,6 +138,42 @@ function image_theme() { 'getsize' => TRUE, ), ), + 'image_style_list' => array( + 'arguments' => array('styles' => NULL), + ), + 'image_style_effects' => array( + 'arguments' => array('form' => NULL), + ), + 'image_style_preview' => array( + 'arguments' => array('style' => NULL), + ), + 'image_anchor' => array( + 'arguments' => array('element' => NULL), + ), + 'image_resize_summary' => array( + 'arguments' => array('data' => NULL), + ), + 'image_scale_summary' => array( + 'arguments' => array('data' => NULL), + ), + 'image_crop_summary' => array( + 'arguments' => array('data' => NULL), + ), + 'image_rotate_summary' => array( + 'arguments' => array('data' => NULL), + ), + ); +} + +/** + * Implement hook_permission(). + */ +function image_permission() { + return array( + 'administer image styles' => array( + 'title' => t('Administer image styles'), + 'description' => t('Create and modify styles for generating image modifications such as thumbnails.'), + ), ); } @@ -154,8 +290,8 @@ function image_styles() { * An image style array containing the following keys: * - "isid": The unique image style ID. * - "name": The unique image style name. - * - "effects": An array of effects within this style. - * If the style name or ID is not valid, an empty array is returned. + * - "effects": An array of image effects within this image style. + * If the image style name or ID is not valid, an empty array is returned. * @see image_effect_load() */ function image_style_load($name = NULL, $isid = NULL) { @@ -185,7 +321,7 @@ function image_style_load($name = NULL, $isid = NULL) { * @param style * An image style array. * @return - * A style array. In the case of a new style, 'isid' will be populated. + * An image style array. In the case of a new style, 'isid' will be populated. */ function image_style_save($style) { if (isset($style['isid']) && is_numeric($style['isid'])) { @@ -242,9 +378,9 @@ function image_style_delete($style, $replacement_style_name = '') { * @param $style * An image style array. * @return - * An array of effects associated with specified style in the format - * array('isid' => array()), or an empty array if the specified style has - * no effects. + * An array of image effects associated with specified image style in the + * format array('isid' => array()), or an empty array if the specified style + * has no effects. */ function image_style_effects($style) { $effects = image_effects(); @@ -464,10 +600,10 @@ function image_style_path($style_name, $path) { } /** - * Pull in effects exposed by other modules using hook_image_effect_info(). + * Pull in image effects exposed by modules implementing hook_image_effect_info(). * * @return - * An array of effects to be used when transforming images. + * An array of image effects to be used when transforming images. * @see hook_image_effect_info() * @see image_effect_definition_load() */ @@ -498,13 +634,13 @@ function image_effect_definitions() { } /** - * Load the definition for an effect. + * Load the definition for an image effect. * - * The effect definition is a set of core properties for an effect, not + * The effect definition is a set of core properties for an image effect, not * containing any user-settings. The definition defines various functions to - * call when configuring or executing an effect. This loader is mostly for + * call when configuring or executing an image effect. This loader is mostly for * internal use within image.module. Use image_effect_load() or - * image_style_load() to get effects that contain configuration. + * image_style_load() to get image effects that contain configuration. * * @param $effect * The name of the effect definition to load. @@ -545,7 +681,7 @@ function image_effects() { foreach ($result as $effect) { $effect['data'] = unserialize($effect['data']); $definition = image_effect_definition_load($effect['name']); - // Do not load effects whose definition cannot be found. + // Do not load image effects whose definition cannot be found. if ($definition) { $effect = array_merge($definition, $effect); $effects[$effect['ieid']] = $effect; @@ -564,10 +700,10 @@ function image_effects() { * @return * An image effect array, consisting of the following keys: * - "ieid": The unique image effect ID. - * - "isid": The unique image style ID that contains this effect. - * - "weight": The weight of this effect within the image style. - * - "effect": The name of the effect definition that powers this effect. - * - "data": An associative array of configuration options for this effect. + * - "isid": The unique image style ID that contains this image effect. + * - "weight": The weight of this image effect within the image style. + * - "name": The name of the effect definition that powers this image effect. + * - "data": An array of configuration options for this image effect. * Besides these keys, the entirety of the image definition is merged into * the image effect array. Returns FALSE if the specified effect cannot be * found. @@ -585,7 +721,7 @@ function image_effect_load($ieid) { * @param $effect * An image effect array. * @return - * An image effect array. In the case of a new effect 'ieid' will be set. + * An image effect array. In the case of a new effect, 'ieid' will be set. */ function image_effect_save($effect) { if (!empty($effect['ieid'])) { @@ -619,7 +755,7 @@ function image_effect_delete($effect) { * @param $effect * An image effect array. * @return - * TRUE on success. FALSE if unable to perform effect on image. + * TRUE on success. FALSE if unable to perform the image effect on the image. */ function image_effect_apply($image, $effect) { if (drupal_function_exists($effect['effect callback'])) { |