You are here

function _imagecache_token_generate_image in Imagecache Token 7

Helper function to generate image style if does not exist.

Parameters

string $styled_uri: URI for image style.

string $type: Machine name for image style.

string $field_uri: URI of field to be styled.

1 call to _imagecache_token_generate_image()
imagecache_token_tokens in ./imagecache_token.tokens.inc
Implements hook_tokens().

File

./imagecache_token.tokens.inc, line 268

Code

function _imagecache_token_generate_image($styled_uri, $type, $field_uri) {

  // Only generate the image if it doesn't already exist.
  if (!file_exists($styled_uri)) {
    $style = image_style_load($type);

    // Imagecrop module support.
    global $imagecrop_style;
    $imagecrop_style = $type;

    // Create a derivative of the image for this style.
    image_style_create_derivative($style, $field_uri, $styled_uri);
  }
}