1 image.tokens.inc image_token_info()

Implements hook_token_info().

File

core/modules/image/image.tokens.inc, line 10
Builds placeholder replacement tokens for image styles.

Code

function image_token_info() {
  $styles = image_styles();
  $field_tokens = array();
  $style_tokens = array();

  foreach ($styles as $style => $definition) {
    $field_tokens[$style] = array(
      'name' => $style,
      'description' => t('@style image style', array('@style' => $style)),
      'type' => 'image-style',
    );
    foreach (_image_style_token_image_attributes() as $attribute => $none) {
      $style_tokens[$attribute] = array(
        'name' => $attribute,
        'description' => t('@style image style attribute: @attribute', array('@style' => $style, '@attribute' => $attribute)),
      );
    }
  }

  return array(
    'types' => array(
      'image-field' => array(
        'name' => 'Image field',
        'description' => 'Image field',
        'needs-data' => 'image-field',
      ),
      'image-style' => array(
        'name' => 'Image style',
        'description' => 'Image style',
        'needs-data' => 'image-style',
      ),
    ),
    'tokens' => array(
      'image-field' => $field_tokens,
      'image-style' => $style_tokens,
    ),
  );
}