function textimage_deliver in Textimage 7.2
Todo.
1 call to textimage_deliver()
- _textimage_preset_flush in ./
textimage.admin.inc - Flush cached media for a preset.
1 string reference to 'textimage_deliver'
- textimage_menu in ./
textimage.module - Implements hook_menu().
File
- ./
textimage.module, line 712 - Provides text to image manipulations.
Code
function textimage_deliver($pid, $filename, $display_img = TRUE) {
$stream_wrapper = file_stream_wrapper_get_instance_by_scheme(variable_get('file_default_scheme', 'public'));
if ($stream_wrapper instanceof DrupalLocalStreamWrapper) {
$directory_path = $stream_wrapper
->getDirectoryPath();
}
else {
drupal_not_found();
}
$public_file_path = base_path() . $directory_path . '/textimage/';
$pattern = '/' . str_replace('/', '\\/', $public_file_path) . '/';
$trail = urldecode(preg_replace($pattern, '', request_uri()));
$args = explode('/', $trail);
$preset = array_shift($args);
$filename = array_pop($args);
$additional_text = $args;
// Determine our output format.
$offset = strrpos($filename, '.');
if ($offset) {
$format = substr($filename, $offset + 1);
}
else {
$format = 'png';
}
if ($format == 'jpg') {
$format = 'jpeg';
}
$filemime = 'image/' . $format;
// Determine the text to display.
$text = preg_replace('/\\.([a-z]+)$/i', '', $filename);
$img_uri = textimage_preset_formatter(array(
'method' => 'url',
'pid' => $pid,
'preset' => $pid,
'text' => $text,
'additional_text' => $additional_text,
'image' => array(
'uri' => variable_get('file_default_scheme', 'public') . "://textimage/{$pid}/{$filename}",
'filename' => $filename,
'filemime' => $filemime,
),
));
if (!$img_uri) {
drupal_not_found();
}
if ($display_img) {
$img_info = image_get_info(drupal_realpath($img_uri));
file_transfer($img_uri, array(
'Content-Type' => $filemime,
));
}
}