function color_field_hex2rgba in Color Field 7.2
Helper: Convert HEX6 to RGBA.
Parameters
string $hex: The colors specified as an hexadecimal format (a hex triplet) (134E1A).
float $alpha: The opacity value ranging for 0 to 1.
Return value
string $rgba The colors specified as an RGB triplet plus the opacity.
1 call to color_field_hex2rgba()
- color_field_field_formatter_view in ./
color_field.field.inc - Implements hook_field_formatter_view().
File
- ./
color_field.module, line 132
Code
function color_field_hex2rgba($hex, $alpha = 1) {
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, -2));
$a = $alpha;
return 'rgba(' . implode(compact('r', 'g', 'b', 'a'), ',') . ')';
}