You are here

function image_style_path_token in Drupal 7

Generates a token to protect an image style derivative.

This prevents unauthorized generation of an image style derivative, which can be costly both in CPU time and disk space.

Parameters

$style_name: The name of the image style.

$uri: The URI of the image for this style, for example as returned by image_style_path().

Return value

An eight-character token which can be used to protect image style derivatives against denial-of-service attacks.

2 calls to image_style_path_token()
image_style_deliver in modules/image/image.module
Page callback: Generates a derivative, given a style and image path.
image_style_url in modules/image/image.module
Returns the URL for an image derivative given a style and image path.

File

modules/image/image.module, line 1076
Exposes global functionality for creating image styles.

Code

function image_style_path_token($style_name, $uri) {

  // Return the first eight characters.
  return substr(drupal_hmac_base64($style_name . ':' . $uri, drupal_get_private_key() . drupal_get_hash_salt()), 0, 8);
}