You are here

function theme_barcode_image in Barcode 7.2

Same name and namespace in other branches
  1. 6.2 barcode.module \theme_barcode_image()

Theme function for the barcode image.

2 theme calls to theme_barcode_image()
barcode_example_example in modules/barcode_example/barcode_example.module
barcode_field_formatter_view in ./barcode.module
Implements hook_field_formatter_view().

File

./barcode.module, line 76

Code

function theme_barcode_image($variables) {
  if (empty($variables['barcode_value'])) {
    return '';
  }
  $barcode = barcode_get_settings();
  if (isset($variables['encoding'])) {
    $barcode['encoding'] = $variables['encoding'];
  }
  $variables['image_format'] = $variables['image_format'] ? $variables['image_format'] : $barcode['image_format'];
  $variables['encoding'] = $variables['encoding'] ? $variables['encoding'] : $barcode['encoding'];
  $variables['height'] = $variables['height'] ? $variables['height'] : $barcode['height'];
  $variables['barcolor'] = $variables['barcolor'] ? $variables['barcolor'] : $barcode['barcolor'];
  $variables['bgcolor'] = $variables['bgcolor'] ? $variables['bgcolor'] : $barcode['bgcolor'];
  $variables['scale'] = $variables['scale'] ? $variables['scale'] : $barcode['scale'];
  module_load_include('inc', 'barcode', 'includes/barcode.plugins');
  $filename = barcode_generate_image($barcode, $variables);
  if (!$filename) {
    drupal_set_message(t('An error occured while generating the barcode.'), 'error');
    return '';
  }
  return theme('image', array(
    'path' => $filename,
    'alt' => $variables['barcode_value'],
    'title' => $variables['barcode_value'],
    'attributes' => array(
      'class' => array(
        'barcode',
      ),
    ),
  ));
}