function theme_textimage_formatter in Textimage 7.3
Same name and namespace in other branches
- 6.2 textimage.module \theme_textimage_formatter()
- 7.2 textimage.module \theme_textimage_formatter()
Theme function to format a Textimage.
5 theme calls to theme_textimage_formatter()
- TextimageApiTest::testTextimageApi in tests/
textimage.test - Test functionality of the API.
- TextimageTest::testTextimage in tests/
textimage.test - Test functionality of the module.
- textimage_field_formatter_view in ./
textimage.module - Implements hook_field_formatter_view().
- theme_textimage_direct_image in ./
textimage.module - Theme function to get a Textimage from a programmatical image style.
- theme_textimage_style_image in ./
textimage.module - Theme function to get a Textimage from a stored image style.
File
- ./
textimage.module, line 840 - Textimage - Provides text to image manipulations.
Code
function theme_textimage_formatter($variables) {
$output = NULL;
// Get URI to image file.
if ($variables['textimage'] && $variables['textimage'] instanceof Textimage) {
$image_uri = $variables['textimage']
->getUri();
}
else {
$data = array(
'style_name' => $variables['style_name'],
'effects' => $variables['effects'],
'text' => $variables['text'],
'target_uri' => $variables['target_uri'],
'extension' => $variables['format'],
'caching' => $variables['caching'],
'node' => $variables['node'],
'source_image_file' => $variables['source_image_file'],
'force_hashed_filename' => $variables['force_hashed_filename'],
);
$image = TextimageImager::getTextimage($data);
$image_uri = $image
->getUri();
}
// Render through theme_image.
if ($image_uri) {
$image_info = image_get_info($image_uri);
// Get the <img>.
$output = theme('image', array(
'path' => $image_uri,
'width' => $image_info['width'],
'height' => $image_info['height'],
'alt' => TextimageImager::processTextString($variables['alt'], NULL, $variables['node'], $variables['source_image_file']),
'title' => TextimageImager::processTextString($variables['title'], NULL, $variables['node'], $variables['source_image_file']),
'attributes' => $variables['attributes'],
));
$image_url = file_create_url($image_uri);
// Wrap the <img> in a container if requested.
if (!empty($variables['image_container_attributes'])) {
$container_attributes = array();
foreach ($variables['image_container_attributes'] as $key => $value) {
$container_attributes[$key] = str_replace('#textimage_derivative_url#', $image_url, $value);
}
$output = theme('container', array(
'element' => array(
'#attributes' => $container_attributes,
'#children' => $output,
),
));
}
// Use the output to build a link if href specified.
if ($variables['href']) {
$options['html'] = TRUE;
$href = $variables['href'] == '#textimage_derivative_url#' ? $image_url : $variables['href'];
$output = l($output, $href, $options);
}
}
return $output;
}