hook_image_default_styles

function hook_image_default_styles

hook_image_default_styles()

Provide module-based image styles for reuse throughout Drupal.

This hook allows your module to provide image styles. This may be useful if you require images to fit within exact dimensions. Note that you should attempt to re-use the default styles provided by Image module whenever possible, rather than creating image styles that are specific to your module. Image provides the styles "thumbnail", "medium", and "large".

You may use this hook to more easily manage your site's changes by moving existing image styles from the database to a custom module. Note however that moving image styles to code instead storing them in the database has a negligible effect on performance, since custom image styles are loaded from the database all at once. Even if all styles are pulled from modules, Image module will still perform the same queries to check the database for any custom styles.

Return value

An array of image styles, keyed by the style name.

See also

image_image_default_styles()

Related topics

File

modules/image/image.api.php, line 176
Hooks related to image styles and effects.

Code

function hook_image_default_styles() {
  $styles = array();

  $styles['mymodule_preview'] = array(
    'label' => 'My module preview',
    'effects' => array(
      array(
        'name' => 'image_scale',
        'data' => array('width' => 400, 'height' => 400, 'upscale' => 1),
        'weight' => 0,
      ),
      array(
        'name' => 'image_desaturate',
        'data' => array(),
        'weight' => 1,
      ),
    ),
  );

  return $styles;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!image!image.api.php/function/hook_image_default_styles/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部