Closed (fixed)
Project:
Barcode
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 May 2010 at 14:49 UTC
Updated:
10 Oct 2011 at 13:01 UTC
I suggest you add an API level function called makeimage, to be used independently of theming. A higher level version of barcode_generateimage
So function theme_barcode_image($barcode_value, $encoding = NULL) becomes
function theme_barcode_image($barcode_value, $encoding = NULL) {
if (empty($barcode_value)) {
return '';
}
$filename = barcode_makeimage ($barcode_value, $encoding);
if (!$filename) {
drupal_set_message(t('An error occured while generating the barcode.'), 'error');
return '';
}
return theme('image', $filename, $barcode_value, $barcode_value, array('class' => 'barcode'));
}
and the function is the bulk of that function.
function barcode_makeimage ($barcode_value, $encoding = NULL) {
$barcode = barcode_get_settings();
$barcode['value'] = $barcode_value;
if (isset($encoding)) {
$barcode['encoding'] = $encoding;
}
module_load_include('inc', 'barcode', 'includes/barcode.plugins');
$filename = barcode_generate_image($barcode);
return $filename;
}
To me that's more useful than the lower-level function because it encapsulates all the variability in making an image and hides details. Not sure about the makeimage name though.
Comments
Comment #1
skyredwang