⚠️ Deprecated - This Craft CMS 2.x plugin is no longer supported.
Barcode is a Craft CMS plugin that allows you to generate a barcode image (Or HTML) in your templates using Twig.
This was built for a project that required barcodes to be generated in Twig and exported via a PDF.
It uses the PHP Barcode Generator (https://github.com/picqer/php-barcode-generator) library and includes all the options from there.
- Add the
barcode
directory into yourcraft/plugins
directory. - Navigate to Settings -> Plugins and click the "Install" button.
There is only one method that you can use - generate.
{{ craft.barcode.generate(
{
code: '8745364267452',
barcodeImageType: 'svg',
type: 'TYPE_CODE_128'
}
) }}
Name | Type | Default Value | Required | Description |
code | string | null | Yes | The code data the barcode should be generated from. |
barcodeImageType | string | null | Yes | Image type you want to output the barcode as. Accepts svg, png, jpg or html (Must be lowercase) |
type | string | null | Yes | The type of barcode you want to output, accepts all the 'Accepted types' from https://github.com/picqer/php-barcode-generator#accepted-types. |
color | string | 000000 | --- | Foreground colour of the barcode, accepts all HEX codes (Without the #) |
width | integer | 2 | --- | Width is based on the length of the data, with this you can make the barcode bars wider. |
height | integer | 30 | --- | Height of the barcode in pixels. |
Barcode Scanner by ProSymbols from Noun Project (https://thenounproject.com/prosymbols/)