You are here

function textimage_image in Textimage 7.2

Same name and namespace in other branches
  1. 5.2 textimage.module \textimage_image()
  2. 5 textimage.module \textimage_image()
  3. 6.2 textimage.module \textimage_image()

Menu Callback function.

Converts the current textimage path into an image. On first request, the image is returned to the browser from Drupal and then saved to the disk. On subsequent requests (with Clean URLs enabled), the cached image is loaded directly.

This function takes a dynamic number of arguments.

+

Parameters

$preset_name: The name of the preset to be used in this textimage +@param ... An unlimited number of additional text parameters to be used as the display text for textimages displayed on top of one another. Only used if the current preset has the its Background Image option set to the result of another preset. Text is used in reverse order. So the last directory will be the first chained preset used. +@param $text The text to be displayed in this preset with the output format appended as the file extension. For example, 'sample.png' will output a PNG with the text 'sample'. 'sample.jpg' will output the same image but in JPG format.

1 string reference to 'textimage_image'
textimage_menu in ./textimage.module
Implements hook_menu().

File

./textimage.module, line 278
Provides text to image manipulations.

Code

function textimage_image() {
  $pattern = '/' . str_replace('/', '\\/', base_path() . '(\\?q=)?' . variable_get('file_default_scheme', 'public') . '://textimage/') . '/';
  $args = explode('/', preg_replace($pattern, '', request_uri()));
  $preset = array_shift($args);
  if (is_numeric($preset)) {
    drupal_not_found();
    exit;
  }
  $filename = urldecode(array_pop($args));
  $additional_text = $args;

  // Determine our output format.
  preg_match('/\\.([a-z]+)$/i', $filename, $matches);
  $format = $matches[1];
  if ($format == 'jpg') {
    $format = 'jpeg';
  }

  // Determine the text to display.
  $text = preg_replace('/\\.([a-z]+)$/i', '', $filename);
  if (!($img = textimage_build_image('url', $preset, $text, $additional_text, $format))) {
    return FALSE;
  }
  drupal_goto($img);
}